ARTIFACTORY: How to avoid displaying sensitive information in the Artifactory Docker Info tab

AuthorFullName__c
Janardhana JL
articleNumber
000006019
FirstPublishedDate
2024-01-30T09:43:09Z
lastModifiedDate
2025-07-22

ARTIFACTORY: How to avoid displaying sensitive information in the Artifactory Docker Info tab

In Artifactory when we build and publish the docker image and if a docker file contains a command with any sensitive information Docker Info tab displays normal command details. It is an expected behavior, the Docker Info tab shows the command used to create the layer, Artifactory looks deep into the images stored in your Docker registries. Select any image in Artifactory’s tree browser and select the Docker Info tab. Artifactory shows the entire history of commands used to select the tag along with its digest, similar to what you would get running docker history.  

This behavior remains consistent across Docker registries. The screen capture demonstrates the same image being pushed to both Docker Hub and Artifactory, with the corresponding command details displayed.
User-added image

User-added image

 




Hence it is recommended not to use any sensitive information such as user credentials API Keys/Tokens ..etc in the docker file to avoid displaying it in the Docker info tab during Tag/Layer visualization.

There is no direct option or workaround to mask these details due to the inherent behavior of Docker. To address this requirement, we recommend utilizing a ``.netrc” file, which securely stores the necessary credentials for logging in and authorizing access to your data.
 
On Mac, UNIX, or Linux systems, the netrc file must be a text file named “.netrc” (dot netrc), residing in your home directory where the Dockerfile is located.  The file's permissions should be set so that only you, the user, can read it (e.g., Read - 400, or Read/Write - 600), making it inaccessible to others.

As a next step, within your Dockerfile, copy the “.netrc” file to the root user's home directory inside the image. By employing this approach, the curl command will automatically authenticate using the credentials from the “.netrc” file, eliminating the need to pass them as environment variables during the build process. To implement this solution, create a file named “.netrc” in the same directory as your Dockerfile. In this file, specify the credentials required for the Artifactory API. Please ensure the correctness of the information provided in the “.netrc” file to ensure seamless authentication.

Below is the sample test case example:

1. Create a .netrc file in the same location where you have a Dockerfile.
Ex:

$ cat .netrc 
machine artifactory.com
login admin
password Password

Note: You will need to replace artifactory.com with the correct DNS name used for Artifactory

2. Then construct the command by proving the .netrc file location:

RUN curl -k -Lvv --netrc-file /root/.netrc --trace-ascii curl_trace.txt -X GET "http://artifactory.com/artifactory/api/system/configuration" -v


3. Sample docker file:

FROM ubuntu:latest
RUN apt-get update && apt-get install -y curl && apt-get install -y nginx
# Copy the .netrc file into the image
COPY .netrc /root/.netrc
# Run the curl command to fetch information from the API
RUN curl -k -Lvv --netrc-file /root/.netrc --trace-ascii curl_trace.txt -X GET "http://artifactory.com/artifactory/api/system/configuration" -v
# Start nginx in the foreground (or any other command you need)
CMD ["nginx", "-g", "daemon off;"]


4. Build the image “DOCKER_BUILDKIT=0 docker build -t test-image:1 . --no-cache”
 
Also as another option, we can use the Docker secrets to Manage the sensitive data.