Quantcast
Channel: Java mon amour
Viewing all articles
Browse latest Browse all 1124

Using Nexus 3 as a Docker registry Proxy

$
0
0
http://books.sonatype.com/nexus-book/3.0/reference/docker.html#docker-proxy


If you are behind a firewall, you need to open :

https://registry-1.docker.io
https://index.docker.io/


As explained here https://hub.docker.com/r/sonatype/nexus3/ I run

docker run -d -p 8081:8081 -p 8082:8082 --name nexus sonatype/nexus3

Port 8082 will be used uniquely for our Docker Proxy Repository

You can open in your browser http://localhost:8081/ and login as admin/admin123

At this point, Docker is still not setup in Nexus:

docker login localhost:8082

Username: admin
Password:
Error response from daemon: login attempt to http://localhost:8081/v2/ failed with status: 404 Not Found




In Nexus console, create a new Docker Proxy repo name "dockerproxy" , URL "https://registry-1.docker.io", Docker index "use docker hub". Also, "enable docker v1 api" checkbox. Choose a port HTTP 8082 !!!

You should be able to see its (empty for now) index here http://localhost:8081/service/rest/repository/browse/dockerproxy/


To configure your docker engine to communicate to the registry:

sudo vi /etc/docker/daemon.json

Add this line:

{"insecure-registries" : [ "localhost:8082" ]}

Restart Docker Daemon:

systemctl daemon-reload

systemctl restart docker

Tag and push your first image:

#check your local images

docker images

#log into nexus registry

docker --debug=true login localhost:8082 -u admin -p admin123

docker run localhost:8082/hello-world

You should be able to see the new image in http://localhost:8081/service/rest/repository/browse/dockerproxy/v2/library/hello-world/

You can also create a hosted Docker repository, better if you create a user pippo/pippo and give it access to the Docker Repository,

then "docker login localhost:8082 -u pippo -p pippo" and to push something
docker tag : localhost:8082/: #example: docker tag service:1.2 localhost:8082/service:1.2

#push your tagged image to nexus
docker push nexus-nodejs:8082/service:1.2



Troubleshooting:

Also, in the Nexus request.log (in /nexus-data/log) I see
172.17.0.1 - - [21/Mar/2018:10:28:19 +0000] "GET /v2/ HTTP/1.1" 404 1783 8 "docker/18.03.0-ce-rc4 go/go1.9.4 git-commit/fbedb97 kernel/3.10.0-693.21.1.el7.x86_64 os/linux arch/amd64 UpstreamClient(Docker-Client/18.03.0-ce-rc4 \(linux\))"



If instead of 8082 you specify 8081 you get this:

docker run localhost:8081/hello-world

Unable to find image 'localhost:8081/hello-world:latest' locally
Pulling repository localhost:8081/hello-world
docker: Error: image hello-world:latest not found.
See 'docker run --help'.




Viewing all articles
Browse latest Browse all 1124

Trending Articles