Fro our local computer, we are going to upload a container to a Docker private registry using command line.
Create an access token
The fist step is to create an access token for an account via the DockerHub account. Login to your Docker account and create an access token from the page "Account Settings -> Security". Copy the access token.
Login to Docker in command line
By using the Docker runtime in command line, we are going to login to Docker. Run the command:
docker login --username [username]
At the password prompt, enter the access token that we have created earlier.
At that stage, Docker runtime has created an entry in the file:
~/.docker/config.json
Example of contents:
{ "auths": { "https://index.docker.io/v1/": { "auth": "[auth value in base 64]" } } }
That file contain the access token encoded in a base64 format. If we want, we can decode it to a normal text format with the command:
echo "[auth value in base 64]" | base64 -d
Upload a container into a Docker private repo
Build a docker container:
docker build -t [repository name]/[container name]:[version] .
For example:
docker build -t reactivetechio/reactive-tech-website:latest .
Push the container:
docker push [repository name]/[container name]:[version] .
For example:
docker push reactivetechio/reactive-tech-website:latest
From that point, the container is availabe in the Docker private repository.
Additional readings
The official Docker doc about the login command.