Tag:

编译后的二进制文件不能在Ubuntu主机上的高山docker容器中运行

给定一个使用GO编译的二进制文件,使用GOOS=linux和GOARCH=amd64 ,部署到基于alpine:3.3 GOARCH=amd64容器,如果docker引擎主机是Ubuntu(15.10),二进制文件将不会运行: sh: /bin/artisan: not found 如果Docker引擎主机是在Mac OS X上的VirtualBox虚拟机中部署的busybox (这是alpine的基础),那么这个相同的二进制文件(针对相同的操作系统和arch编译)将运行得很好 。 如果容器基于Ubuntu镜像之一,这个相同的二进制文件也可以很好的运行。 任何想法这个二进制丢失? 这是我所做的重现(成功运行在VirtualBox / OS X上的busybox未显示): build立(即使拱门匹配,用标志显式build立): ➜ artisan git:(master) ✗ GOOS=linux GOARCH=amd64 go build 检查一下可以在主机上运行: ➜ artisan git:(master) ✗ ./artisan 10:14:04.925 [ERROR] artisan: need a command, one of server, provision or build 复制到docker目录,生成,运行: ➜ artisan git:(master) ✗ cp artisan docker/build/bin/ ➜ artisan […]

Go运行时使用的线程数

Go运行时(调度程序,垃圾回收器等)可以使用多less个线程? 例如,如果GOMAXPROCS是10 ,运行时会使用多less个内核线程? 编辑: 我正在阅读在Go 1.5 GOMAXPROCS更改为runtime.NumCPU() 。 有一句话声称,“由于运行时间的并行性,特别是垃圾收集器,通过提高GOMAXPROCS可以提高单个程序的性能。” 我真正的问题是:如果我有一个运行在具有CPU配额的Docker容器中的单个goroutine程序,那么为了获得最高的性能,我需要的逻辑处理器的最小数量是多less。

如何等待POST请求完成在GO?

您好我正在GO中创build一个POST请求,但它实际上完成之前终止,例如我想拉一个docker图像,这可以通过以下curl来完成: curl -X POST https://address/images/create?fromImage=imagename 这返回以下内容 {"status":"Pulling from imagename","id":"latest"} {"status":"Already exists","progressDetail":{},"id":"3d30e94188f7"} {"status":"Already exists","progressDetail":{},"id":"bf4e27765153"} {"status":"Already exists","progressDetail":{},"id":"67280fd39fba"} …. many of those {"status":"Pull complete","progressDetail":{},"id":"21c062e2346f"} {"status":"Digest: sha256:24f26a1344fca6d5ee1adcdsf2d01b20d7823c560ed9d2193466e36bd1f049088"} {"status":"Pulling from imagename","id":"20161005"} {"status":"Digest: sha256:f527dsfds88676eb25d8f7de5406f46cbc3a995345ddb4bb3d08fcf110458fe3cf"} {"status":"Status: Downloaded newer image for imagename"} 并且图像被成功拉出 但如果我尝试从走 func PullImage(imagename string, uuid string) error { logFields := log.Fields{ "handler": "PullImage", "uuid": uuid, } log.WithFields(logFields).Debugf("imagename:%v", imagename) url := […]

如果标签名称中包含“。”,我如何得到一个Docker镜像的标签?

docker inspect命令对于在Docker镜像上获取标签非常有用: # -*- Dockerfile -*- FROM busybox LABEL foo="bar" LABEL com.wherever.foo="bang" 对于简单的标签名称,inspect命令有一个很好的工具 – –format选项(使用Go模板)。 $ docker build -t foo . $ docker inspect -f '{{ .Config.Labels.foo }}' foo bar 但是,如何访问名称中有点的标签呢? $ docker inspect -f '{{ .Config.Labels.com.wherever.foo }}' foo <no value> 我正在写一个bash脚本,我想避免重新parsingdocker inspect的JSON输出,如果可能的话。

扩展dockerpostgres图像来创build额外的数据库

我已经看到了这个主题: https : //stackoverflow.com/a/26599273/2323245 但是我有以下问题: postgres_1 | FATAL: role "docker" does not exist app_1 | Error: Could not establish a connection with the database 这是我的docker-compose.yml文件 version: "2" services: app: build: context: . dockerfile: Dockerfiles/app.dockerfile links: – postgres depends_on: – postgres ports: – "8080:8080" environment: PORT: 8080 networks: – neo_dev restart: always postgres: build: context: . […]

使用Go Docker API从挂载的文件获取文件上下文

我正在尝试使用Go docker API获取已装入的文件内容: 文件secret.txt存储一行TOKEN=MY_TOKEN 码: cli, err := client.NewEnvClient() if err != nil { panic(err) } defer cli.Close() ctx := context.Background() _, err = cli.ImagePull(ctx, "alpine", types.ImagePullOptions{}) if err != nil { panic(err) } containerConfig := &container.Config{ Image: "alpine", Cmd: []string{"echo", "hello world"}, } // mounted file h := container.HostConfig{ Binds: []string{"/etc/secret.txt"}, } resp, err […]

使用Elastic Beanstalk在AWS上转到Web应用程序,不会在日志中显示输出

这是一个深入的问题,所以我会尽力解释它。 我在Go中构build了一个小的API服务,我试图使用相对较新的AWS Elastic Beanstalk Docker 支持部署到AWS。 这就是我所做的(代码全部是开源的,所以如果你愿意的话,你可以按照下面的步骤): $ git clone https://github.com/rdegges/ipify-api.git $ cd ipify-api $ git fetch origin aws:aws $ git checkout aws $ eb init $ eb create $ eb deploy 这将使用弹性beanstalk创build一个新的应用程序(与docker),并部署它。 如果我然后运行eb open我的web应用程序,我会看到我的公共IP地址(这是正确的行为),所以我知道我的应用程序正在运行/function。 现在,在我的源代码中,我有几行debugging输出: fmt.Println("WOOOOOOOOOOOO") 上面的语句只是打印“WOO …”到控制台。 每次发出新的请求时都会执行此操作。 不幸的是,当我运行eb logs来查看我的实例日志时,这个debugging行从来没有出现 – 我不明白为什么。 我试过打印到STDERR,打印到STDOUT等 – 但我绝对不能得到任何输出。 我search了互联网寻找解决scheme,但还没有find任何解决scheme。

我如何确保kubernetes的优雅缩放?

作为kubernetes中缩放荚的一部分,我希望确保在closures之前我优雅地服务于我的http连接。 就这点而言,我已经在go中实现了这个代码: package main import ( "fmt" "io" "net/http" "os" "os/signal" "syscall" "github.com/braintree/manners" ) func main() { shutdown := make(chan int) //create a notification channel to shutdown sigChan := make(chan os.Signal, 1) //start the http server http.HandleFunc("/", hello) server := manners.NewWithServer(&http.Server{Addr: ":80", Handler: nil}) go func() { server.ListenAndServe() shutdown <- 1 }() //register for interupt […]

fork / exec ./debug:操作不允许

我的目标是能够从Atom.io远程debugging。 进入Docker容器,运行在dlvdebugging器中 。 这是第一个问题: 更新:1。 我在Mac上运行Docker容器,但是这不应该影响代码签名的事情,因为我在一个容器中运行,对不对? 更新:2。 Codesignig主机,没有帮助。 Error: 1. root@…:/go/src/app# go get github.com/derekparker/delve/cmd/dlv 2. root@…:/go/src/app# dlv debug hello.go could not launch process: fork/exec ./debug: operation not permitted 然后试图 1. root@…:/go/src/app# sudo 2. bash: sudo: command not found