how to reconnect to a docker container

不问归期 提交于 2019-12-10 10:03:39

问题


I have a docker container running ubuntu and a simple node express site.

I connected to the container as follows

docker run -i -t -p 8080:3000 node-express

The node app in the container is running with pm2, so it continues once I exit out of the container.

CONTAINER ID        IMAGE
f32de2737e80        node-express:latest

Now assume I want to make an update to my app.

I assume I need to connect to the container, stop the node app, and make an update, e.g. git pull then restart it.

My first question is how do I reconnect to this container?

Another question I have, Is this a normal approach for updating a running container in production?


回答1:


You can consider docker exec to open a bash in your running container.

See also "difference between docker attach and docker exec"

docker exec -it f32de2737e80 bash

But as commented, updated the app should be done by modifying a Dockerfile and rebuilding an image.



来源:https://stackoverflow.com/questions/31580015/how-to-reconnect-to-a-docker-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!