Issue
This Content is from Stack Overflow. Question asked by tao
I have a Dockerfile and docker-compose.yml in my go project.
It is the contents of Dockerfile
FROM golang:1.7
RUN set -x;
export DEBIAN_FRONTEND=noninteractive;
echo "deb http://ppa.launchpad.net/bpaquet/zeromq4-precise/ubuntu precise main " >> /etc/apt/sources.list
&& apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys FF160426C4832F92
&& apt-get update
&& apt-get install -y
libzmq1=4.0.4-bpa~precise1
libzmq-dev=4.0.4-bpa~precise1
pkg-config
ENV PATH /go/bin:$PATH
ENV GOPROJECTPATH /go/src/emitter
COPY . $GOPROJECTPATH
WORKDIR $GOPROJECTPATH
RUN go get -v
CMD ["bash"]
It is the docker-compose.yml
dev:
build: .
volumes:
- .:/go/src/emitter
working_dir: /go/src/emitter
command: bash
net: host
When I try building an image by running:
docker build –tag docker-task .
I have the below error in my terminal
[+] Building 4.3s (9/9) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 37B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/golang:1.7 1.5s
=> [1/5] FROM docker.io/library/golang:1.7@sha256:93b2b52f1212e97b6650bde1f20f6a359b08c117c57a848970d615fe88623a3d 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 277B 0.0s
=> CACHED [2/5] RUN set -x; export DEBIAN_FRONTEND=noninteractive; echo "deb http://ppa.launchpad.net/bpaquet/zeromq4-precise/ubuntu precise ma 0.0s
=> CACHED [3/5] COPY . /go/src/emitter 0.0s
=> CACHED [4/5] WORKDIR /go/src/emitter 0.0s
=> ERROR [5/5] RUN go get -v 2.8s
------
> [5/5] RUN go get -v:
#9 0.809 github.com/pebbe/zmq4 (download)
#9 2.680 github.com/pebbe/zmq4
#9 2.754 # github.com/pebbe/zmq4
#9 2.754 runtime: failed to create new OS thread (have 2 already; errno=22)
#9 2.754 fatal error: newosproc
#9 2.754
#9 2.754 runtime stack:
#9 2.754 runtime.throw(0x5ba65a, 0x9)
#9 2.754 /usr/local/go/src/runtime/panic.go:566 +0x95
#9 2.754 runtime.newosproc(0xc42002a000, 0xc420039fc0)
#9 2.754 /usr/local/go/src/runtime/os_linux.go:160 +0x194
#9 2.754 runtime.newm(0x5d6628, 0x0)
#9 2.754 /usr/local/go/src/runtime/proc.go:1572 +0x132
#9 2.754 runtime.main.func1()
#9 2.754 /usr/local/go/src/runtime/proc.go:126 +0x36
#9 2.754 runtime.systemstack(0x688400)
#9 2.754 /usr/local/go/src/runtime/asm_amd64.s:298 +0x79
#9 2.754 runtime.mstart()
#9 2.754 /usr/local/go/src/runtime/proc.go:1079
#9 2.754
#9 2.754 goroutine 1 [running]:
#9 2.754 runtime.systemstack_switch()
#9 2.754 /usr/local/go/src/runtime/asm_amd64.s:252 fp=0xc420024768 sp=0xc420024760
#9 2.754 runtime.main()
#9 2.754 /usr/local/go/src/runtime/proc.go:127 +0x6c fp=0xc4200247c0 sp=0xc420024768
#9 2.754 runtime.goexit()
#9 2.754 /usr/local/go/src/runtime/asm_amd64.s:2086 +0x1 fp=0xc4200247c8 sp=0xc4200247c0
------
executor failed running [/bin/sh -c go get -v]: exit code: 2
So my question is what the error about, and how to pass the build.
many thanks
Solution
Is this the new MacBook with M1/M2 chip?
If yes, then:
- Use this in Dockerfile:
FROM --platform=linux/amd64 golang:1.7
OR - Set
DOCKER_DEFAULT_PLATFORM=linux/amd64
enviromental variable
This Question was asked in StackOverflow by tao and Answered by Abhishek S It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.