This session we will push the image to docker registry
Lab1 : Push an image to docker registry
Login to hub.docker.com and select the free account [verify account, if you have just signed up]
From command line do the docker login
docker login
docker image tag myimage amitow/myimage
amitow: Name of the docker registry name space
myimage: ImageName
Note: If no tag provided, this would be latest tag.
docker image push amitow/myimage
Lab2: Create a Private Registry and Push Docker Image
To create a private Docker registry and push an image, follow these steps:
- Install Docker Registry on a server or a cloud-based platform of your choice. You can use a Docker image to do this. For example:
docker run -d -p 5000:5000 --restart=always --name registry registry:2
This will start a Docker Registry container listening on port 5000.
- Build your Docker image, and tag it with the address of your private registry:
docker tag myimage localhost:5000/my-image
- Push the image to your private registry:
docker push localhost:5000/my-image
4. Verify that the image is in the registry by running:
curl http://localhost:5000/v2/_catalog
This should return a JSON object containing the name of your image.
5. Pull the image from your private registry:
docker pull localhost:5000/my-image
You can now use this image on any Docker host that has access to your private registry.