Tag:

Docker与nginx反向代理到golang服务器的问题

我有nginx反向代理到一个golang服务器,每个在它自己的docker集装箱,并正常运行。 当我尝试连接到Go容器时,在我的本地Mac机器上和生产服务器Linux Debian上,我都不断收到nginx的这个错误。 一周前它在我的本地Mac机器上工作,突然之间,它就不复存在了 nginx_1 | 2017/09/28 01:29:54 [error] 5#5: *12 upstream timed out (110: Connection timed out) while connecting to upstream, client: 172.23.0.1, server: , request: "GET /api/about HTTP/1.1", upstream: "http://67.199.248.12:8080/api/about", host: "localhost" 有人可以解释这里发生了什么? 什么是67.199.248.12,为什么Nginx不能ping /连接到Go容器? Go容器中的/ etc / hosts里面有什么 127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters […]

Docker(GitLab CI本地亚军):“Mounts denied”

我使用GitLab CI和优秀的本地GitLab CI runner来testing阶段,然后使用docker exec方法推送它们。 我使用Golang作为我select的语言,并且根据官方build议,最近将我的$GOPATH从~/go到/go 。 但是,现在当我尝试testing我的构build时,出现以下错误消息: ERROR: Job failed (system failure): Error response from daemon: Mounts denied: The path /go/src/[redacted] is not shared from Docker -> Preferences… -> File Sharing. 将代码移回到我的主目录下的文件夹,它再次工作。 试图在消息中修复出现另一个错误: rm: cannot remove 'rm: cannot remove '/go/src/[redacted]': Read-only file system 它试图删除当前的本地工作目录(这是我的实际存储库,所以我显然不希望这样)。 什么是正确的方式来configurationDocker(或跑步者)能够在我的$GOPATH ? 谢谢你的时间。

Golang Docker API在点击ImageBuild时报告无效的参数

我有以下代码从包含Dockerfile的.tar文件构build图像。 os.MkdirAll("configs/container",0755) tar := new(archivex.TarFile) tar.Create("configs/container/conf.tar") tar.AddAll("configs/configdir", false) tar.Close() dockerBuildContext, err := os.Open("config/dns/conf.tar") defer dockerBuildContext.Close() buildOptions := types.ImageBuildOptions{ Context: dockerBuildContext, CPUSetCPUs: "2", CPUSetMems: "12", CPUShares: 20, CPUQuota: 10, CPUPeriod: 30, Memory: 256, MemorySwap: 512, ShmSize: 10, CgroupParent: "cgroup_parent", Dockerfile: "Dockerfile", // optional, is the default Tags: []string{"coolimage"}, } cli, err := client.NewEnvClient() buildResponse, err := […]

Docker容器崩溃 – 之后有问题的pipe理容器

我运行: docker:Docker版本17.03.0-ce,build 60ccb22 linux:Ubuntu 16.04.2 LTS docker集装箱内的图像运行一些golang应用程序,这(我发现这知道)不正确地处理错误。 我应该包括os.Exit(1)像我的情况下,进行错误检查。 我运行/启动docker容器像命令一样 docker run -it –restart=always –env-file ~/PRODUCTION/services/resolvment_api/.environmet_variables -p 8081:3003 –name resolvment_2 -d resolvment-api 好吧,那么它看起来像在应用程序级别的泊坞窗容器内发生错误。 此时,Docker / Docker容器发生了一些奇怪的事情。 如果我做docker ps我可以看到 2e7b02258647 resolvment-api "/bin/sh -c $GOBIN…" 9 days ago Up 37 hours 0.0.0.0:8081->3003/tcp resolvment_2 我可以做docker logs 2e7b02258647并会看到日志。 如果我尝试做docker stop 2e7b02258647我通常在成功停止容器时,在下一行中获取容器ID。 然后,如果我再次做docker ps …我仍然可以看到docker容器(具有相同的ID)在那里列出?! 如果我再试图强行与取出容器docker rm -f 2e7b02258647我得到一个错误, Error response […]

在部署到Docker的情况下,在Golang中实现的Apache Kafka消费者恐慌

这里是我尝试实现一个简单的微服务,它应该读取来自kafka服务器的消息并通过HTTP发送。 它运行正常,当我从terminal运行它,但是当部署在泊坞窗上它恐慌 panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x7b6345] goroutine 12 [running]: main.kafkaRoutine.func1(0xc420174060, 0x0, 0x0) /go/src/github.com/deathcore666/ProperConsumerServiceYo/kafka.go:36 +0x95 created by main.kafkaRoutine /go/src/github.com/deathcore666/ProperConsumerServiceYo/kafka.go:32 +0x1ad kafka.go第32行和第36行是go func(pc sarama.PartitionConsumer)函数的地方。 我对编程相对较新,所以任何帮助,将不胜感激。 谢谢! main.go: func main() { var ( listen = flag.String("listen", ":8080", "HTTP listen address") proxy = flag.String("proxy", "", "Optional […]

GO使用Docker API时发出问题 – 无法导入“nat”

我正在尝试使用可从github.com/docker/docker/client获得的golang docker API。 到目前为止,我能够在图像生成期间预定义的端口上启动容器。 我试图在运行时使用API​​映射端口; 相当于一些东西 docker run -p 8083:8082 -d myImage:1.0.0 我试图做如下的映射端口: host_config := &container.HostConfig{ PortBindings: nat.PortMap{ "8082/tcp": []nat.PortBinding{ { HostIP: "0.0.0.0", HostPort: "8983", }, }, }, } 这里的问题是variables“nat”存在于API的供应商文件夹内。 我无法直接从go供应商文件夹中导入某些内容。 有人build议将复制连接文件夹到github文件夹中,并删除嵌套的供应商目录。 我按照build议做了,并创build了一个path如下: "github.com/docker/go-connections/nat" 现在我在编译期间得到以下错误: src\main\createcontainer1.go:53: cannot use "github.com/docker/go-connections/nat".PortSet literal (type "github.com/docker/go-connections/nat".PortSet) as type "github.com/docker/docker/vendor/github.com/docker/go-connections/nat".PortSet in field value src\main\createcontainer1.go:65: cannot use "github.com/docker/go-connections/nat".PortMap literal (type "github.com/docker/go-connections/nat".PortMap) […]

从用户github源设置一个容器

可以closures,不知道该怎么做。 我现在很坦白地输了,在Github上发布他的源码的用户在发布一个新的分支时没有更新安装说明。 现在,我不是密集的,只是没有受过教育的docker工人。 我真的很感激推动正确的方向。 如果我缺less这篇文章的任何信息,请允许我在评论中提供。 当前设置 O / S – Debian 8 Minimal(最新内核) 硬件 – 1GB VPS(KVM) Docker – 安装了Compose( #docker info ) 我试图设置这个( https://github.com/pboehm/ddns/tree/docker_and_rework ),首先我应该克隆这个混帐到我的工作目录? 比如说/ home。 我将运行以下命令; git clone -b docker_and_rework https://github.com/pboehm/ddns.git 已成功将源文件克隆到/ home / ddns / …( 工作目录 ) 现在,我相信我应该继续前进,并build立一些*,所以我进入以下目录; /home/ddns/docker 里面包含了一个docker-compose.yml文件,我不知道这是干什么的,但是通过查看它,它似乎发送了一堆指令,我只能假定是实际部署或构build整个容器/映像或神奇的东西吧? 从这里我继续做下面的事情; docker-compose build 正如我们所看到的,我相信它build造的容器或图像或任何它所谓的,你明白我的观点( 在这里 )。 一段时间后,完成,我们可以看到以下( docker图像运行 )。 这是正确的,我看到所有的依赖关系,但是像这样的东西; […]

docker中的Golang错误

在构build我的应用程序时,我在Docker中遇到了一个奇怪的错误: ./main.go:31:9: cannot use db (type *"github.com/khwerhahn/somerepo/vendor/github.com/jinzhu/gorm".DB) as type *"app/vendor/github.com/jinzhu/gorm".DB in argument to Migrate The command '/bin/sh -c go-wrapper install' returned a non-zero code: 2 有人可以提示我进入正确的方向,因为本地的应用程序运行得很好。 它只是在docker集装箱内。 我用glide来pipe理依赖关系。 Dockerfile: FROM golang:1.9 WORKDIR /go/src/app COPY . . RUN go-wrapper download RUN go-wrapper install CMD ["go-wrapper", "run"] ////编辑这是我的结构看起来如何。 Glidepipe理供应商文件夹。 dockerbuild设rest。

Docker Windows授予构build代理用户的权限

我想configuration一个GoCD代理来使用docker来构build我的项目。 原来我的GoAgents是作为SYSTEM运行的,因为这是Windows上的默认安装,但是我发现在编译期间(由于$ env:TEMP没有被定义或者被定义在一个奇怪的地方而导致奇怪的失败)。 我将我的代理人切换到本地帐户,并授予该帐户权限以作为服务运行。 这工作得很好,直到我试图build立docker图像。 我有一个脚本,作为我的用户完美工作,但作为GoCD代理运行时失败。 error during connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.32/build?buildargs=%7B%22EngineDir%22%3A%22C%3A%5C%5CInfinity%22%2C%22ImageVersion%22%3A%222.0.0%22%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&rm=1&session=29985a28e57e1f1b4fa8950cfa0f747b4c2680fa5f4fcb3643f68b4595825651&shmsize=0&t=invoke-infinity%3Alatest&t=invoke-infinity%3A2.0.0&target=&ulimits=null: open //./pipe/docker_engine: Access is denied. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running. 我已经尝试将用户添加到docker-users组,但似乎没有帮助。 我试着按照这篇文章http://dille.name/blog/2017/11/29/using-the-docker-named-pipe-as-a-non-admin-for-windowscontainers/但是得到和错误说Docker Windows不支持“主机”。 有没有人有任何方式在Windows上的非pipe理员用户运行docker构build? 谢谢

Go的时间不适用于从头开始的docker形象

转到代码: package main import ( "fmt" "time" ) func main() { var local,_ = time.LoadLocation("Asia/Shanghai") fmt.Println(time.Now()) fmt.Println(time.Now().In(local)) } Dockerfile: FROM scratch COPY ./main /main CMD [ "/main" ] build.sh: rm -rf main CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o main . docker build -t hello-go . docker run hello-go 所有文件都在一个名为hello-go的文件夹中。 当我在我的osx中运行Go代码时。 有用。 ➜ hello-go go run […]