How Do You Upload Files to Nexus 3 in a Docker Container on Linux CentOS?

Problem scenario
You want to upload files into Nexus 3 running in a Docker container.  You installed Nexus 3 with Docker 1.9 using these directions. The OS is CentOS 7.2.  The web UI for Nexus 3 works via Docker, but you cannot upload files into any repository. When you go to Repositories, but you do not see the "Artifact tab."  How do you upload files?

Solution
Prerequisite
Install Docker; if you need assistance, see this link.

Procedures
It does not matter if Maven is installed or not.  The only prerequisite to Nexus 3 is JRE (the Java Runtime Environment).  If you want directions installing the Java Development Kit (which includes the JRE), see this posting.  While this solution can be done interactively, this solution is a programmatic way of uploading artifacts.  It can enable scripting and getting around using the web UI manually.

First, find the correct URL for the repository.  Open a web browser and go to the URL. Log into Nexus 3's web UI.  The default username is admin with a password of "admin123" (with no quotes).  Go to Repository -> Repositories.  Look at the "Type:" column and find one that is not "group" nor "proxy."  A repository should have the Type of "hosted."  Obtain the value in the "URL" column for the repository you want.

From a Linux server with access to the URL for Nexus 3 (usually the IP address of the Linux server that houses Docker with ":8081" at the end of it), run this command:

curl -v -u jdoe:P@$$w0rd --upload-file /tmp/artifactfile http://123.123.123.123:8081/artifactfile

# where...

1.  http://123.123.123.123:8081/ is the URL that you copied in the first part of this solution.   
2.  /tmp/ is the path to the file you want to upload
3.  artifactfile is the name of the file you want to upload
4.  jdoe is the username that can log into the Nexus 3 web URL
5.  P@$$w0rd it the password for jdoe

The above command will allow you to upload files to Nexus 3.

Leave a comment

Your email address will not be published. Required fields are marked *