While creating and managing Docker Containers, Docker Images play an important role. Docker Images are base of containers that can help you in rapid provisioning of Docker Containers either for base containers or custom containers with your own applications.
In continuation to our previous article where we introduced Docker Containers and discussed about installing Docker Container on cloud. We have talked about packaging your application into Docker Image. Now let’s discuss about the different options available to store and distribute your Docker Images for your different requirements.
For storing and distributing Docker Images, Docker allows you to create centralized store from where you can pull and push your Docker images anytime. This storage either can be configured locally on Docker host or on the cloud.
Docker Registry is a server side application that allows you to store and distribute Docker Images. Docker Registry provides stateless storage option to store Docker images with flexibility to scale up and down to meet your ever changing requirements. The Registry is an open source, under the permissive Apache license.
Docker Registry provides you better control to manage where your Docker images are being stored. Apart from storing Docker Images, Docker Registry offers content delivery system where you can manage your own Docker image distribution pipeline.
Let’s have a glance how you can start using your Docker Registry. You can deploy Docker Registry Server for two different use cases, mentioned below:
Before deploying Docker Registry, ensure you must have Docker version 1.6.0 or higher installed.
docker run -d -p 5000:5000 –restart=always –name registry registry:2
docker pull ubuntu && docker tag ubuntu localhost:5000/ubuntu
docker push localhost:5000/Ubuntu
docker pull localhost:5000/ubuntu
To deploy Docker Registry Server on Domain, it’s recommended to use Transport Layer Security (TLS). Here are some high level steps:
docker stop registry && docker rm -v registry
docker run -d -p 5000:5000 –restart=always –name registry \
-v `pwd`/certs:/certs \
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \
-e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \
registry:2
docker pull ubuntu
docker tag ubuntu abcd.com:5000/ubuntu
docker push abcd.com:5000/ubuntu
docker pull abcd.com:5000/ubuntu
Alternate of option for Docker Registry is Docker Hub. The Docker Hub is managed service to provide cloud-based registry services that helps in building and distributing containers for applications and services. Docker Hub offers a centralized repository that allows you to perform container image discovery, container image distribution and automation workflow across the development pipeline.
Docker Hub provides multiple features including image repositories, automated builds, webhooks and organizations. In this article we will only cover feature of image repositories as an alternate for Docker Registry for storing and distributing Docker Images. Docker Hub also allows you to integrate with GitHub and Bitbucket where you can trigger the Docker Hub in case of rebuilding repositories after changes made to the repositories.
Docker Hub’s repository feature allows you to store Docker Images, push/pull images from communities and separating official and private image libraries. You can use Docker Hub services either through Docker Command Line tool or through Docker Hub web portal. Here are some high level steps to get started with Docker Hub:
Note: You can create private or organizational repository where access to the new repository will be available either to you only (private repository) or across departments within your organization (organizational repository).
Stay tuned!!!