Skip to main content

Command Palette

Search for a command to run...

How To Dockerize An Application- Part II

Published
1 min read
How To Dockerize An Application- Part II
S

I’m an open source enthusiast and I am passionate Web Development, DevOps & I enjoy learning new things.

What is Dockerize?

Dockerizing is the process of packing, deploying, and running applications using Docker containers.

Chose a base image

You can start from a Base OS and install everything by yourself. Choose an image based on the used technology, such as Node, Java, Ruby, and Python. I am going to use Node for my hello-world application.

  • 1. Create a file hello-world.js

      Console.log("Hello World");
    
  • 2. Create a Dockerfile in the root directory with the same name Dockerfile and write the following instructions

      FROM node:alpine
      COPY ./app
      WORKDIR /app
      CMD node app.js
    
    • 3. Build the Docker image from this Dockerfile, you can run the following command from the directory containing the Dockerfile. This will create a Docker image with the tag `hello-world`

        docker build -t hello-world .
      
      • 4. Finally, you can run the Docker container from the image using the following command

          docker run hello-world
        

More from this blog

Learn Full Stack Web dev. The ultimate guide

32 posts

Full Stack Developer @Codepillars | Web3.0 | Node.js