1. Creating a Docker Hub Account

Docker Hub is a public registry where you can store and share your Docker images.


Steps to create an account:

  1. Navigate to: https://hub.docker.com/
  2. Click on Sign Up and fill in your details.
  3. Agree to the terms and conditions.
  4. Verify your email through the confirmation link.
  5. Log in using your new credentials.

Once you have an account, you can pull images from Docker Hub with: docker pull <image-name>


Example: docker pull ubuntu

2. Committing Changes to a Container


Sometimes, you may need to modify a running container (e.g., installing software) and save it as a new image.


Example: Installing Apache inside an Ubuntu container

  1. Pull the base image: docker pull ubuntu
  2. Run the container: docker run -it -d ubuntu
  3. Access the container: docker exec -it <container-id>
  4. Inside the container, install Apache: apt-get update , apt-get install apache2
  5. Exit the container and commit changes: docker commit <container-id> <dockerhub-username>/<image-name>

Example: docker commit 4f3b2c1d7e12 mydockeruser/ubuntu-apache

Now you have a custom image ready to be pushed.


3. Pushing the Container Image to Docker Hub

  1. Log in to Docker Hub from the terminal: docker login
  2. Push the committed image: docker push <dockerhub-username>/<image-name>
  3. Verify on Docker Hub: Go to your Docker Hub account, and you'll see the uploaded image. Anyone can now pull it using: docker pull mydockeruser/ubuntu-apache

Recap

  • Docker Hub lets you store and share images.
  • docker commit allows you to save container changes as an image.
  • docker push helps you publish your images for reuse.

Mastering these steps is essential for building efficient CI/CD pipelines in any DevOps workflow.