How to connect to a docker container

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

I am connected to container like this

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

      

The container node app runs from pm2, so it continues as soon as I log out of the container.

CONTAINER ID        IMAGE
f32de2737e80        node-express:latest

      

Now let's say I want to update my application.

I guess I need to connect to the container, stop the node app and do an update, eg. git pull

, then restart it.

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

Another question I have is, is this the usual approach for updating a running container in production?

+3


source to share


1 answer


You might consider docker exec

to open bash in your working container.

See also " difference between docker attachment and docker exec "



docker exec -it f32de2737e80 bash

      

But in the comments, the updated app should be done by modifying the Dockerfile and rebuilding the image.

+7


source







All Articles