As a best practice, it is recommended to pull/push Docker images with a normal user (not root/sudo).
We suggest that you create a group named ‘docker’ and assign a new or existing user to be a member of that group. The docker client will check to see if a given user is a member of the ‘docker’ group; if so, it will allow that user to push using the ‘.dockercfg’ configuration that is deployed in the user’s home directory.
To achieve this, perform the following steps (This assumes you will be working in a Linux environment):
- Run the following commands. (Replace ‘<user>’ with your username):
- sudo groupadd docker
- sudo gpasswd -a <user> docker
- sudo service docker restart
- Logout with the user that you have just added to group docker and then log in again with that user.
- Using the user account, run the curl command for generating the ‘.dockercfg’–file and store it in the user’s home directory:
- curl -u<user>:<password> ‘https://docker.jfrog.com/v1/auth’
Note that “docker.jfrog.com” is an example for the Artifactory URL that points to the reverse proxy that handles the https requests and redirects to the docker repository in an Artifactory Pro instance.