Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ENTRYPOINT exec form instead of shell form #6

Merged
merged 1 commit into from
May 16, 2020
Merged

Use ENTRYPOINT exec form instead of shell form #6

merged 1 commit into from
May 16, 2020

Conversation

futek
Copy link
Contributor

@futek futek commented May 16, 2020

The image has no shell at /bin/sh so the ENTRYPOINT shell form does not work:

$ docker run --rm itzg/rcon-cli:1.4.7 --help
Unable to find image 'itzg/rcon-cli:1.4.7' locally
1.4.7: Pulling from itzg/rcon-cli
8839a1e05eed: Pull complete
Digest: sha256:8470c29d26d7abc1475d2adc4b5e5a6f746a788763f511757bf179c39e3f26c9
Status: Downloaded newer image for itzg/rcon-cli:1.4.7
docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"/bin/sh\": stat /bin/sh: no such file or directory": unknown.
$ GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o rcon-cli .
$ docker build -t rcon-cli .
Sending build context to Docker daemon   12.2MB
Step 1/3 : FROM scratch
 --->
Step 2/3 : COPY rcon-cli /
 ---> 0dd2badd83fe
Step 3/3 : ENTRYPOINT /rcon-cli
 ---> Running in d81dcc3f9b4c
Removing intermediate container d81dcc3f9b4c
 ---> 327b6d337275
Successfully built 327b6d337275
Successfully tagged rcon-cli:latest
$ docker run --rm rcon-cli --help
docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"/bin/sh\": stat /bin/sh: no such file or directory": unknown.

You can work around it by overriding the ENTRYPOINT of the image:

$ docker run --rm --entrypoint /rcon-cli itzg/rcon-cli:1.4.7 --help

rcon-cli is a CLI for attaching to an RCON enabled game server, such as Minecraft.
Without any additional arguments, the CLI will start an interactive session with
the RCON server.

...

Using the ENTRYPOINT exec form instead (i.e. ENTRYPOINT ["/rcon-cli"]) makes it work out of the box:

$ GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o rcon-cli .
$ docker build -t rcon-cli .
Sending build context to Docker daemon   12.2MB
Step 1/3 : FROM scratch
 --->
Step 2/3 : COPY rcon-cli /
 ---> Using cache
 ---> 0dd2badd83fe
Step 3/3 : ENTRYPOINT [ "/rcon-cli" ]
 ---> Running in a96eb138ebf7
Removing intermediate container a96eb138ebf7
 ---> d649b44a2dca
Successfully built d649b44a2dca
Successfully tagged rcon-cli:latest
$ docker run --rm rcon-cli --help

rcon-cli is a CLI for attaching to an RCON enabled game server, such as Minecraft.
Without any additional arguments, the CLI will start an interactive session with
the RCON server.

...

The image has no shell at /bin/sh so the shell form does not work
Copy link
Owner

@itzg itzg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that's embarrassing. I defined the docker build but apparently never tested the image. Thanks for fixing this!

@itzg itzg merged commit 6ab7bbd into itzg:master May 16, 2020
@futek futek deleted the fix-docker-entrypoint branch May 16, 2020 17:22
@itzg
Copy link
Owner

itzg commented May 16, 2020

Latest image (at 1.4.8) includes your fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants