Why does “docker attach” hang?

前端 未结 6 2070
借酒劲吻你
借酒劲吻你 2020-12-13 17:17

I can run an ubuntu container successfully:

# docker run -it -d ubuntu
3aef6e642327ce7d19c7381eb145f3ad10291f1f2393af16a6327ee78d7c60bb
# dock         


        
6条回答
  •  我在风中等你
    2020-12-13 17:32

    I ran into this issue as well when attempting to attach to a container that was developed by someone else and already running a daemon. (In this case, it was LinuxServer's transmission docker image).

    Problem:

    What happened was the terminal appeared to 'hang', where typing anything didn't help and wouldn't show up. Only Ctrl-C would kick me back out.

    docker run, docker start, docker attach all was not successful, turns out the command I needed (after the container has been started with run or start) was to execute bash, as chances are the container you pulled from doesn't have bash already running.

    Solution:

    docker exec -it bash

    (you can find the container-id from running docker ps -a).

    This will pull you into the instance with a functional bash as root (assuming there was no other explicit set up done by the image you pulled).

    I know the accepted answer has captured this as well, but decided to post another one that is a little more terse and obvious, as the solution didn't pop out for me when I was reading it.

提交回复
热议问题