Dockerize your application

Assuming that you have read out about what is docker, I am listing the steps to be followed to dockerize an application.

Prerequisite: Install docker and docker compose

  1. Install docker and docker-compose
  2. Create an application
  3. Write a Dockerfile
  4. Build the docker image using Dockerfile

    sudo docker build -t DOCKER_HUB_USERNAME/IMAGE_NAME:TAG_NAME .

    Notice dot(.) at the end of command

  5. Run your image
  6. Push your image to docker hub
  7. Create docker-compose.yml

You can create docker image manually or alternatively you can use docker compose to build the image. If you manually created an image, then you can use that image in docker-compose. If image is not at your system then it will check the image on docker hub and pull the image. To understand this scenario:

  • Create an image
  • Push image to docker hub
  • Remove the image from your system
  • When you execute docker-compose up, it will pull the image from docker hub

Leave a Reply

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

Back to Top