There are different tools provides docker registry, and in this tutorial, we want to use Sonatype Nexus Repository Manager as our docker registry, and we will upload our images in there.
I am using the CentOS7 server in google cloud to install Nexus. You may need to change the script based on your requirements. Also as a pre-requisite this script needs SELinux and FIREWALL need to be disabled, In case if you want to run along with those, then you need to modify the scripts as the requirement.
1. Install Nexus Repository.
Run the following command to install Sonatype Nexus Repository Manager, and it starts the service automatically.
Note: Ensure you run the script as root user.
# curl -s https://raw.githubusercontent.com/linuxautomations/nexus/master/install.sh | bash
You can view the output as follows.
2. Open the repository over browser with 8081 default port of Nexus.
You can view the web portal of Nexus as follows.
3. Next, navigate as follows and create the repository.
Sign In -> Username & Password (Default username & password : admin / admin123 )
Then click on Settings as shown in the below image.
Then click on Repositories in the left pane and then click on create the repository and then select docker (hosted).
And fill in the details as follows.
Finally, Click on Create repository.
Then the created repository will be shown as below.
4. Let's try to login to nexus repository from docker node.
Add the following configuration to docker.
# cat /etc/docker/daemon.json
{
"insecure-registries" : ["nexus:9001"]
}
# systemctl restart docker
#
You might be execpected the following output.
5. Finally, create an image and push to nexus repo and verify the repository.
# docker tag centos nexus:9001/centos
# docker push nexus:9001/centos
The push refers to a repository [nexus:9001/centos]
e15afa4858b6: Pushed
latest: digest: sha256:7e94d6055269edb455bcfb637292573117e4a8341e9b9abbc09b17d8aafe8fbe size: 529