Faizuddin Mohammed Faizuddin Mohammed - 10 days ago 5
Node.js Question

How to make changes to the code inside a Docker Container?

I'm completely new to Docker and Containers. I'm also new to the entire VM concepts.

I understand that VM and Dockers are a way to make all the dependencies of an application to be available as a single component that you can easily deploy on clouds that support them.

I installed Docker on my local machine (an Ubuntu) and I used used this guide to download and run the Node Official Image.

What I need to know now is how do I make code changes for the files inside of Docker? I made changes to the 'server.js' inside the app and when I navigate to

http://locahost:49160
the browser still shows the output from the old
server.js
. I restarted the container and yet I get the same old output.

I see that I can commit changes and make a new image. But then, isn't the old image completely useless?

Or am I not at all understanding how things with Docker work?

Answer

You could make changes inside an container and could even commit these changes to the original image or create a new image as well as.

But I recommend you to create a new images or tags.

Review the guide. When you want to make a change on server.js, let do it but build a new image for it also. Don't forget to add a tag (test1).

Example, docker build -t <your username>/node-web-app:test1 .

Then you could run the new image with docker run -p 49160:8080 -d <your username>/node-web-app:test1

Comments