Chris G.
Chris G.

Reputation: 25924

reconnect to container as the original "docker run"

I have some containers running and once in a while the connection is lost in the terminal. The container is still running perfectly. How do I reconnect to the samme user process?

The problem is: When I do docker exec -it name bash, I get a new root user. But then I need to stop the applications the original user started to get them into this bash.

How do you reconnect to the original running user process/bash.

info: using mac terminal.

Upvotes: 20

Views: 10368

Answers (2)

mainframer
mainframer

Reputation: 22059

docker ps -a                 # list all the containers and find your container
docker start <container ID>  # start the exited container 
docker attach <container ID> # attach to your container

Upvotes: 11

askb
askb

Reputation: 6768

You would need to use the docker attach <container ID>

refer: man docker-attach

"

The docker attach command allows you to attach to a running container using the container's ID or name, either to view its ongoing output or to control it interactively. You can attach to the same contained process multiple times simultaneously, screen sharing style, or quickly view the progress of your daemonized process.

You can detach from the container (and leave it running) with CTRL-p CTRL-q (for a quiet exit) or CTRL-c which will send a SIGKILL to the container. When you are attached to a con‐ tainer, and exit its main process, the process's exit code will be returned to the client.

"

Upvotes: 23

Related Questions