Wrapping Up

To fully complete the Nexus3 setup, we will now be adding our docker registry references. Your host file should have three entries now. The new ones are your docker registry to allow push and pulls.

127.0.0.1	nexus.acme.com
127.0.0.1	docker.acme.com
127.0.0.1	docker-private.acme.com

Next, we need to configure Docker desktop to allow our insecure registries. Remember, we are sitting behind a self-signed certificate on NGINX pointing to our local machine.

Addition of insecure registries in daemon.json

In the above, you can see the new registries added, one for your own private images, and one for all public and private images combined. To simplify the aspect of tagging for public/private we also added a few helper scripts for docker-push and docker-pull.

labimages
#!/bin/bash

tag=$1
host=$2

docker tag $tag $host/$tag
docker push $host/$tag
docker image rm $host/$tag

sleep 5
#!/bin/bash

tag=$1
host=$2

docker pull $host/$tag
docker tag $host/$tag $tag
docker image rm $host/$tag

sleep 5

Publishing your images

The following infrastructure grade images are ready to be published.

> docker image ls | grep infra
REPOSITORY                  TAG       IMAGE ID       CREATED              SIZE
infra/nginx/base            1.0.0     475e7e36f13e   x minutes ago        160MB
infra/sonatype/nexus3       1.0.0     b22a14b5e9e3   x minutes ago   	  511MB
infra/java/openjdk-8        1.0.0     ee57978b9c1b   x minutes ago   	  323MB
infra/nginx/build           1.0.0     cdcfa991852c   x minutes ago        159MB
infra/ubuntu/focal          1.0.0     2d35d9f34150   x minutes ago        72.9MB

When publishing we publish against our private repo (docker-private.acme.com), on pulling we generally recommend pulling from our group repo (docker.acme.com).

#publish first against private
docker login docker-private.acme.com
images/docker-push.sh infra/ubuntu/focal:1.0.0 docker-private.acme.com
images/docker-push.sh infra/java/openjdk-8:1.0.0 docker-private.acme.com
images/docker-push.sh infra/sonatype/nexus3:1.0.0 docker-private.acme.com
images/docker-push.sh infra/nginx/build:1.0.0 docker-private.acme.com
images/docker-push.sh infra/nginx/base:1.0.0 docker-private.acme.com

#final sanity check, pull image
docker image rm infra/ubuntu/focal:1.0.0
docker login docker.acme.com
images/docker-pull.sh infra/ubuntu/focal:1.0.0 docker.acme.com