I’m trying to spin up a golang alpine docker container (just the basic image) and immediately connect to it to run commands, but I can’t seem to specify the correct shell program.
docker run -d golang:1.20-alpine --entrypoint=bin/sh
ec90a5d5eeba63e509acc09e234054d883aa122cd7617f89b61e7d71220847cd
docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "--entrypoint=bin/sh": stat --entrypoint=bin/sh: no such file or directory: unknown.
I’ve also tried: /bin/sh
. What am I missing here?
2
Answers
I’ll just write an answer instead of commands in comments.
To spin up a golang alpine docker container (just the basic image) and immediately connect to it to run commands, you can do this:
If you want to name your container, you could do this:
You can stop the container with
docker stop test5 -t 2
and start it up again usingdocker start test5
.You can remove it by doing
docker rm test5
.You can change your command just a little bit to avoid the error:
Notice that the
--entrypoint
command line switch is before golang:1.20-alpine.The error you’re facing is because you’re incorrectly passing the –entrypoint parameter when running the Docker container.
In the command you’re using:
The –entrypoint parameter is being interpreted as a command to be executed inside the container instead of specifying the entry point of the container.
To fix this error, you need to adjust the command and use the -it option to interact with the container. Here’s a possible solution:
In this command, sh is used as the entry point of the container. The -it option allows interaction with the container through a terminal.
This way, you should be able to connect to the container and execute commands inside it.
I hope this solution helps you resolve the issue and allows you to run commands within the Golang Alpine Docker container.