skip to Main Content

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


  1. 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:

    docker run -it golang:1.20-alpine /bin/sh
    

    If you want to name your container, you could do this:

    docker pull golang:1.20-alpine
    docker run -id --name=test5 golang:1.20-alpine
    docker exec -it test5 /bin/sh
    

    You can stop the container with docker stop test5 -t 2 and start it up again using docker start test5.

    You can remove it by doing docker rm test5.


    You can change your command just a little bit to avoid the error:

    docker run -d --entrypoint=/bin/sh golang:1.20-alpine
    

    Notice that the --entrypoint command line switch is before golang:1.20-alpine.

    Login or Signup to reply.
  2. 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:

    docker run -d golang:1.20-alpine --entrypoint=bin/sh
    

    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:

    docker run -it golang:1.20-alpine sh
    

    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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search