Dockerize an application in less than 3 minutes

Everyone knows Docker. Docker is a set of tools that use OS-level virtualization to deliver software in packages called containers. If you have never tried Docker before, this guide is a perfect place to start. Follow these instructions and it will take less than 3 minutes to Dockerize your first application.

Step 1. Install Docker. Follow the instructions for your platform:

Step 2. Install Node.js. The application we will containerize is written on Node.js. Therefore, we need tooling that will allow us to test the application locally without a container first. However, of course, we can use an application that is written in any other language.

Step 3. Download the sample app. Open your terminal and run these commands:



powershell "Invoke-WebRequest -Outfile app.js -Uri"

Step 4. Launch the application locally

node app.js

Step 5. Make sure the application responds on port 3000


or open this address in your browser

Step 6. Create a Docker file. Create a file that is called Dockerfile(without extension) and add the following lines inside

Use node as your base image:

FROM node:latest

copy app.js into your container:

COPY ./app.js .

On a container startup run the application:

CMD node app.js

To summarize, your Dockerfile should look like this:

Step 7. Build your image.

docker build -t nodejs-hello:latest .

Step 8. Run your container.

docker run -d -p 3000:3000 nodejs-hello:latest

Step 9. Validate your container. Make sure the application responds on port 3000. But this time, it is actually being served from the container:


or open this address in your browser.

Congratulations! You have created your first docker image and launched your first container. Let me know in the comments how much time did it take for you.

Apply for individual mentorship here:

Connect with me on LinkedIn:

The success story of my client:

Originally published Feb 18, 2022 4:44:03 AM (updated August 23 2022 )

Leave a Reply

Your email address will not be published. Required fields are marked *