Docker

Docker login Command

Docker is a well-established development platform widely used for project development. It provides many essential components, such as Docker containers, images, Docker client and server, Docker registries, and many more. It also offers an official Docker registry, “Docker Hub”, that contains numerous Docker images and packages. More specifically, in order to log in to Docker registries, the “docker login” command is used.

This blog will explain the usage of the “docker login” command.

What is the “docker login” Command?

In Docker, the registries are two types of Docker official registry, “Docker Hub” introduced by Docker, and the “Docker private registry” created by users. However, the “docker login” command is used for logging in to the Docker registry from the terminal.

How to Use the “docker login” Command?

To log in and log out from Docker registries, we have listed down the methods to use the “docker login” and “docker logout” commands:

How to Login to Docker Official Registry?

In order to log in to Docker’s official registry Docker Hub, utilize the simple “docker login” command. Upon doing so, you will be asked to enter “Username” and “Password”.

Therefore, provide the required credentials to log in to the Docker Hub registry:

> docker login

How to Logout From Docker Official Registry?

To log out of the registry, utilize the “docker logout” command:

> docker logout

How to Login to Docker Private Registry?

Docker’s private registry is created and managed by Docker users. To login to a private registry, users are required to provide registry “domain” along with the “docker login” command.

For instance, we have logged in to our private registry executing on “localhost:5000”:

>docker login localhost:5000

Alternatively, users can specify the username and password in the “docker login” command. For this purpose, the “-u” option is used to specify the username, and “-p” refers to the password:

> docker login localhost:5000 -u rafia098 -p Jenny098

How to Logout From Docker Private Registry?

To log out from Docker private registry, utilize the “docker logout <user-domain>” command:

> docker logout localhost:5000

We have explained what the Docker login command is and how to use it.

Conclusion

The “docker login” is a command line utility of Docker used to log in to the Docker registry from the terminal. In order to log in to the Docker official registry, utilize the “docker login” command. However, to log in to Docker private registry, use the “docker login <user-domain>” command. This write-up has demonstrated the “docker login” command and how to use it.

About the author

Rafia Zafar

I am graduated in computer science. I am a junior technical author here and passionate about Programming and learning new technologies. I have worked in JAVA, HTML 5, CSS3, Bootstrap, and PHP.