Logging in and out of the Docker image registry
In your journey through the world of containerization, oftentimes you will be publishing your images for public consumption or privately sharing images using a Docker registry. To push an image to a public repository, you must log in to a Docker registry and you must be the owner of that repository. In the case of a private repository, both pulling and pushing are allowed, but only once you are logged in. In this recipe, we will see how to log in and log out of a Docker registry.
Getting ready
Ensure that you have a valid Docker ID or GitLab account.
How to do it...
The docker login
command lets you log in to more than one Docker registry at the same time. Similarly, the docker logout
command lets you log out from the specified server. Here is the syntax for the Docker login and logout commands:
$ docker login [OPTIONS] [SERVER] $ docker logout [SERVER]
By default, both the docker login
and docker logout
commands assume https://hub.docker.com/ as...