Pulling Images
Downloading images, also known as pulling, from the repository manager is performed with the docker pull
command. Include the hostname or IP address of the repository manager as well as the repository connector port configured for the repository.
docker pull <nexus-hostname>:<repository-port>/<image>
The following examples download images from Nexus Repository Manager running on the host nexus.example.com
with a repository connector port of 18443
docker pull nexus.example.com:18443/ubuntu docker pull nexus.example.com:18443/bitnami/node docker pull nexus.example.com:18443/postgres:9.4
Official images such as Ubuntu or Postgres belong to the library user on Docker Hub and will therefore show up as library/ubuntu
and library/postgres
in the repository manager.
After a successful pull
, start the container with the run
command.
See the Docker Authentication topic on authentication before pulling an image.
Pulling images during a Jenkins CI job
The following example is a pipeline project in Jenkins that pulls an image from Nexus Repository. Specify an agent node that has Docker installed.
Open Jenkins, and create a new pipeline project. In the Pipeline section, enter the following script:
node { stage('Pull') { sh 'docker pull nexus.example.com:18443/ubuntu' } }
Save the pipeline script and then launch the build in Jenkins.
Docker Build
The docker build command reads instructions in a Dockerfile to build docker images. To download build images from the repository manager, you can specify the hostname or IP address of the repository connector as well as the repository connector port in the FROM line of the Dockerfile.
FROM <nexus-hostname>:<repository-port>/<image>
An example Dockerfile FROM line:
FROM nexus.example.com:18443/nginx