3

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?

svnm
  • 22,878
  • 21
  • 90
  • 105
  • 2
    This wouldn't be scalable if you had more than one container running your application. Normal approach is to modify app in dev environment and rebuild docker image. Then deploy image to docker hosts and start new containers. – Matt Harrison Jul 23 '15 at 06:51

1 Answers1

7

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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250