Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

reconnect to container as the original "docker run"

Tags:

docker

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.

like image 359
Chris G. Avatar asked Oct 29 '15 09:10

Chris G.


2 Answers

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.

"

like image 200
askb Avatar answered Oct 12 '22 02:10

askb


docker ps -a                 # list all the containers and find your containder
docker start <container ID>  # start the exited container 
docker attach <container ID> # attach to your container
like image 25
mainframer Avatar answered Oct 12 '22 03:10

mainframer