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
- Install docker and docker-compose
- Create an application
- Write a Dockerfile
- Build the docker image using Dockerfile
sudo docker build -t DOCKER_HUB_USERNAME/IMAGE_NAME:TAG_NAME .
Notice dot(.) at the end of command
- Run your image
- Push your image to docker hub
- 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