In this exercise, you continue your role as a DevOps engineer at a fast-growing tech startup. After successfully building a multi-stage Docker image for your todo management application, it’s time to share that image with your team by pushing it to Docker Hub. This will enable other developers and environments to pull the image directly, streamlining your deployment process.
You are tasked with pushing the Docker image you created in the previous exercise to Docker Hub. This involves tagging the image correctly, authenticating with Docker Hub, and then pushing the image to a public repository. Once the image is pushed, you'll verify that it can be pulled and used in a different environment.
Tag the Docker Image:
dockerhub-username/repository-name:tag
.multi-stage-latest
).Login to Docker Hub:
docker login
command to authenticate with Docker Hub using your credentials.Push the Image to Docker Hub:
docker push
command.Pull the Image from Docker Hub:
docker pull
command to retrieve the image from Docker Hub.Acceptance Criteria:
Make sure if you are using
sudo
with docker, all commands includingdocker login
should use sudo. Otherwise you may face permission denied issues while pushing docker images.
MULTI-STAGE-BUILDS
)docker login
to authenticate with Docker Hub.docker push
to upload the image to your Docker Hub repository.Try to solve this exercise on your own before looking at the solution.
Tag the Image:
yourusername
:docker tag todo-app-multi-stage:latest yourusername/todo-app:multi-stage-latest
Login to Docker Hub:
docker login
Create a new Repository:
todo-app
.Push the Image:
docker push yourusername/todo-app:multi-stage-latest
Verify the Image:
docker pull yourusername/todo-app:multi-stage-latest
docker run -d -p 8080:8080 --network=todo -e DB_URL=jdbc:mysql://tododb:3306/dockermastery -e DB_USERNAME=root -e DB_PASSWORD=root yourusername/todo-app:multi-stage-latest
http://localhost:8080
in your browser to check if the application is running correctly.By following these steps, you will have successfully pushed your Docker image to Docker Hub and verified that it can be pulled and run in a different environment.