Introduction
Docker is an incredibly useful tool for deploying your servers, applications, and services. Docker takes it a step further with Docker Hub, a public registry where you can store and share your Docker images. However, keep in mind that anything you upload to Docker Hub becomes public. In some cases, you might want to keep your creations private for your own projects.
This guide is here to help you set up your very own Private Docker Registry. By the end of this lab, you’ll be able to push custom Docker images to your private registry and securely pull those images from your hosts.
Docker Registry
The Docker Registry is a powerful, open-source, stateless, and highly scalable server-side application. It’s designed specifically for storing and distributing Docker images.
Logging in as “root” user in your Linux system
Before we dive in, make sure you’re logged in as the “root” user.
Configuring Your Local Docker Registry
Let’s get started by installing the docker-distribution package:
[root@localhost ~]# yum install docker-distribution -y Loaded plugins: fastestmirror, langpacks, product-id, search-disabled-repos, subscription-manager This system is not registered with an entitlement server. You can use subscription-manager to register. Loading mirror speeds from cached hostfile * base: centos.mirror.net.in * extras: centos.mirror.net.in * updates: centos.mirror.net.in Resolving Dependencies --> Running transaction check ---> Package docker-distribution.x86_64 0:2.6.2-2.git48294d9.el7 will be installed --> Finished Dependency Resolution Installing : docker-distribution-2.6.2-2.git48294d9.el7.x86_64 1/1 Verifying : docker-distribution-2.6.2-2.git48294d9.el7.x86_64 1/1 Installed: docker-distribution.x86_64 0:2.6.2-2.git48294d9.el7 Complete!
Listing docker-distribution Contents
You can use the rpm command to list the contents of the docker-distribution package on CentOS. There are nearly 200 files in the package, mostly consisting of Python code. However, the following command will show you only the documentation and configuration files
[root@localhost ~]# rpm -ql docker-distribution /etc/docker-distribution/registry/config.yml /usr/bin/registry /usr/lib/systemd/system/docker-distribution.service /usr/share/doc/docker-distribution-2.6.2 /usr/share/doc/docker-distribution-2.6.2/AUTHORS /usr/share/doc/docker-distribution-2.6.2/CONTRIBUTING.md /usr/share/doc/docker-distribution-2.6.2/LICENSE /usr/share/doc/docker-distribution-2.6.2/MAINTAINERS /usr/share/doc/docker-distribution-2.6.2/README.md /var/lib/registry
Start the docker-distribution service
[root@localhost ~]# systemctl enable docker-distribution Created symlink from /etc/systemd/system/multi-user.target.wants/docker-distribution.service to /usr/lib/systemd/system/docker-distribution.service. [root@localhost ~]# systemctl start docker-distribution [root@localhost ~]# systemctl status docker-distribution ● docker-distribution.service - v2 Registry server for Docker Loaded: loaded (/usr/lib/systemd/system/docker-distribution.service; enabled; vendor preset: disabled) Active: active (running) since Sun 2023-09-10 04:05:34 EDT; 6s ago Main PID: 7724 (registry) Tasks: 6 CGroup: /system.slice/docker-distribution.service └─7724 /usr/bin/registry serve /etc/docker-distribution/registry/config.yml Sep 10 04:05:34 localhost.localdomain systemd[1]: Started v2 Registry server for Docker. Sep 10 04:05:34 localhost.localdomain registry[7724]: time="2023-09-10T04:05:34-04:00" level=warning msg="No HTTP secret provided - generated rando... Sep 10 04:05:34 localhost.localdomain registry[7724]: time="2023-09-10T04:05:34-04:00" level=info msg="redis not configured" go.version=go1....nknown" Sep 10 04:05:34 localhost.localdomain registry[7724]: time="2023-09-10T04:05:34-04:00" level=info msg="Starting upload purge in 35m0s" go.ve...nknown" Sep 10 04:05:34 localhost.localdomain registry[7724]: time="2023-09-10T04:05:34-04:00" level=info msg="using inmemory blob descriptor cache"...nknown" Sep 10 04:05:34 localhost.localdomain registry[7724]: time="2023-09-10T04:05:34-04:00" level=info msg="listening on [::]:5000" go.version=go...nknown" Hint: Some lines were ellipsized, use -l to show in full.