In the previous post, we learned what Docker Registry is. In this post, lets learn more about the basic commands and naming used in registry.
Let's get started by looking at some basic commands -
1. Start your registry
The registry Docker image is configured to start on port 5000 in the container, so we will expose the host port also as 5000.
docker run -d -p 5000:5000 --name registry registry:2
2. Check if the container named ‘registry’ has started via the command
docker ps
3. Pull (or build) some image from the hub
docker pull ubuntu
4. Tag the image so that it points to your registry
docker image tag ubuntu localhost:5000/myfirstimage
5. Now that we have the registry setup and the docker image tagged and ready to be pushed, just enter the below command
docker push localhost:5000/myfirstimage
6. Pull it back
docker pull localhost:5000/myfirstimage
7. Now stop your registry and remove all data
docker container stop registry && docker container rm -v registry
Typical Docker commands utilize image names that indicate their origin.
1. docker pull nginx
This command instructs docker to pull an image named nginx from the official Docker Hub.
2. docker pull myregistrydomain:port/foo/bar
This command instructs docker to contact the registry located at myregistrydomain:port to find the image foo/bar
These are the few commands which we look at running a private registry. This was a registry that did not enforce any authentication on the part of the client. However keep in mind that you should still adhere to the best practices for managing a safe registry.
This article have shed light on the basic Docker commands that we use on a daily basis to properly maintain our running containers and to manage our dockers. Stay tuned for more articles related to Docker.
I hope you find this article helpful.
Thank you for reading!
*** Explore | Share | Grow ***
Comments