Description
Steps to reproduce the issue:
1.Build a static golang simple http server with command: CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -a -installsuffix cgo -o main .
2.Create a Dockerfile
FROM scratch
ADD main /
CMD ["/main"]
3.Build Docker image docker build -t kevingo/http-scratch -f Dockerfile.scratch .
4.Docker run with port binding docker run -p 1234:8080 kevingo/http-scratch
Describe the results you received:
standard_init_linux.go:175: exec user process caused "exec format error"
Describe the results you expected:
Correct run the container without error
Output of docker version:
Client:
Version: 1.12.1
API version: 1.24
Go version: go1.7.1
Git commit: 6f9534c
Built: Thu Sep 8 10:31:18 2016
OS/Arch: darwin/amd64
Server:
Version: 1.12.1
API version: 1.24
Go version: go1.6.3
Git commit: 23cf638
Built: Thu Aug 18 17:52:38 2016
OS/Arch: linux/amd64
Output of docker info:
Containers: 79
Running: 0
Paused: 0
Stopped: 79
Images: 61
Server Version: 1.12.1
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 375
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: null host bridge overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 4.4.20-moby
Operating System: Alpine Linux v3.4
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.953 GiB
Name: moby
ID: 4W7W:QBKE:OVDR:DOML:ZWHI:JKLR:555F:GB6H:BSAR:Q25F:LQGX:YHN6
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 18
Goroutines: 29
System Time: 2016-10-25T08:23:53.429205718Z
EventsListeners: 1
No Proxy: *.local, 169.254/16
Username: kevingo
Registry: https://index.docker.io/v1/
Insecure Registries:
127.0.0.0/8```
@kevingo This should be a mismatch with platform . I run into this issue when I run an amd64 image on an arm64 image by accident. Are your sure the binary you built with CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -a -installsuffix cgo -o main . can run on your host?
GOOS=darwin builds an executable that runs on OSX, you cannot run this in a Linux container. I am closing this as it is expected behaviour. There are no native OSX containers yet, sorry...
@coolljt0725 @justincormack Thanks. I change GOOS to linux, and everything works fine.
For googlers check the Sha-Bang on your Entrypoint and CMD scripts.
I am encountering this same error. It's a tiny php container with my application and it runs fine on my Mac but gives me that error on my raspberry pi. I built it on the Mac and copied the image to the pi and built it on the pi and neither had luck. How would I change "G00S"?
@akath20 the GOOS is something specific to the Go language, so won't help you. For your situation, you'll need a base image that's able to run on ARM, and a PHP version for that architecture as well.
It's probably better to ask this on forums.docker.com or the docker community slack channel
Hello i am getting the same error,..
these are the logs and docekrfile i am using
logs : standard_init_linux.go:187: exec user process caused "exec format error"
FROM openjdk:8-jre
MAINTAINER krish
ENV ARTIFACTORY_HOME=/opt/artifactory
ENV ARTIFACTORY_VERSION=5.4.6
ENV MIN_HEAP_SIZE="-Xms512m"
ENV MAX_HEAP_SIZE="-Xmx2g"
RUN groupadd -g 1000 artifactory \
&& useradd -d "$ARTIFACTORY_HOME" -u 1000 -g 1000 -s /sbin/nologin artifactory
RUN wget "https://api.bintray.com/content/jfrog/artifactory/jfrog-artifactory-oss-${ARTIFACTORY_VERSION}.zip;bt_package=jfrog-artifactory-oss-zip" && \
unzip "jfrog-artifactory-oss-${ARTIFACTORY_VERSION}.zip;bt_package=jfrog-artifactory-oss-zip" && \
mv artifactory-oss-${ARTIFACTORY_VERSION} $ARTIFACTORY_HOME && \
rm "jfrog-artifactory-oss-${ARTIFACTORY_VERSION}.zip;bt_package=jfrog-artifactory-oss-zip"
VOLUME $ARTIFACTORY_HOME/data
VOLUME $ARTIFACTORY_HOME/etc
VOLUME $ARTIFACTORY_HOME/logs
VOLUME $ARTIFACTORY_HOME/backup
VOLUME $ARTIFACTORY_HOME/access
ADD entrypoint.sh /opt/artifactory/bin/entrypoint.sh
RUN chmod 755 /opt/artifactory/bin/entrypoint.sh
RUN chown -R artifactory:artifactory $ARTIFACTORY_HOME
USER artifactory
ENTRYPOINT ["/opt/artifactory/bin/entrypoint.sh"]
EXPOSE 8081
Most helpful comment
For googlers check the Sha-Bang on your Entrypoint and CMD scripts.
!/bin/bash