Nexus3 Docker HTTPS
Introduction
Nexus3 is a popular repository manager that allows you to host and manage your software packages. Docker is a popular containerization platform that allows you to build and run applications in isolated environments. In this article, we will explore how to configure Nexus3 with HTTPS for Docker repositories.
Prerequisites
Before we begin, make sure you have the following prerequisites:
- A running Nexus3 instance
- A domain name and SSL certificate for HTTPS
Configuring Nexus3 with HTTPS
-
Install and configure the SSL certificate
First, you need to obtain an SSL certificate for your domain. This can be done by using a trusted certificate authority or by generating a self-signed certificate. Once you have the certificate files, upload them to your Nexus3 server.
-
Configure Nexus3 to use HTTPS
Open the
nexus.properties
file located in the Nexus3 installation directory. Add the following lines to enable HTTPS:nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml application-port-ssl=8443 nexus-https-port=8443
-
Configure Jetty for HTTPS
Open the
jetty-https.xml
file located in the Nexus3 installation directory. Uncomment the following lines:<Call name="addConnector"> <Arg> <New class="org.eclipse.jetty.server.ServerConnector"> <Arg name="server"> <Ref refid="Server"/> </Arg> <Arg name="factories"> <Array type="org.eclipse.jetty.server.ConnectionFactory"> <Item> <New class="org.eclipse.jetty.server.SslConnectionFactory"> <Arg name="next">http/1.1</Arg> <Arg name="sslContextFactory"> <Ref refid="sslContextFactory"/> </Arg> </New> </Item> <Item> <New class="org.eclipse.jetty.server.HttpConnectionFactory"> <Arg name="config"> <Ref refid="httpConfig"/> </Arg> </New> </Item> </Array> </Arg> <Set name="host"> <Property name="jetty.host" default="localhost"/> </Set> <Set name="port"> <Property name="jetty.ssl.port" default="8443"/> </Set> <Set name="idleTimeout"> <Property name="jetty.timeout" default="30000"/> </Set> <Set name="acceptorPriorityDelta"> <Property name="jetty.acceptorPriorityDelta" default="0"/> </Set> </New> </Arg> </Call>
-
Restart Nexus3
Restart your Nexus3 server to apply the changes. You should now be able to access Nexus3 using HTTPS on port 8443.
Using Nexus3 with Docker
Now that you have configured Nexus3 with HTTPS, let's see how to use it with Docker.
-
Pull or build a Docker image
Use the following command to pull a Docker image from Nexus3:
docker pull <nexus3-domain>/<repository>/<image>:<tag>
Alternatively, you can build a Docker image and push it to Nexus3 using the following commands:
docker build -t <nexus3-domain>/<repository>/<image>:<tag> . docker push <nexus3-domain>/<repository>/<image>:<tag>
-
Authenticate with Nexus3
Before you can push or pull Docker images from Nexus3, you need to authenticate with it. Use the following command:
docker login <nexus3-domain> -u <username> -p <password>
-
Push or pull Docker images
Once authenticated, you can push or pull Docker images to/from Nexus3. Use the following commands:
docker push <nexus3-domain>/<repository>/<image>:<tag> docker pull <nexus3-domain>/<repository>/<image>:<tag>
Conclusion
In this article, we have learned how to configure Nexus3 with HTTPS for Docker repositories. We have also seen how to authenticate and push/pull Docker images from Nexus3. By using HTTPS, you can ensure secure communication between your Docker client and Nexus3 server.