• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to Create a Public/Private Repository in Docker Hub and connect it remotely using command line

by admin

What is a Docker Hub

Docker Hub is the central place used for keeping the Docker images either in a public or private repository. Docker Hub provides features, such as a repository for Docker images, user authentications, automated image builds, integration with GitHub or Bitbucket, and managing organizations and groups. The Docker Registry component of Docker Hub manages the repository for Docker images.

Creating Repository In Dcoker

1. Display the current info about the docker host.

# docker info

2. Using a browser, open the URL “hub.docker.com” and register an id by passing required information.

docker repository hub sign up

3. Once logged in, create the repository. Provide the required details like – Name, Short Description, Detailed description etc. We are making the repository as Public as shown below.

create first docker repository or private hub

Create docker repository - provide required details

4. Below is a public repository after it has been created.
Public repository in docker after creation

Connecting the Docker repository remotely from command line

1. Once the repository is created use the login command from the Docker node to get connected.

# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: geeklab
Password: 
Login Succeeded

2. Once the user has logged in, the info command will show the username assigned to the node.

# docker info
....
Username: geeklab
Registry: https://index.docker.io/v1/

3. The information is stored in the local users home directory. Multiple users in the same host can connect to different repositories.

# cat .docker/config.json
{
        "auths": {
                "https://index.docker.io/v1/": {
                        "auth": "Z2Vla2xhYjp2YXNoaTEyMw=="
                }
        },
        "HttpHeaders": {
                "User-Agent": "Docker-Client/17.10.0-ce (linux)"
        }
}

4. To verify that you have connected correctly to the remote reposityr “geeklab”, use the following command.

# docker search geeklab/*
NAME                DESCRIPTION                 STARS               OFFICIAL            AUTOMATED
geeklab/test_repo   This the first Test repo.   0        

Logout from the docker hub

To logout from the docker login, use the command below :

# docker logout
Removing login credentials for https://index.docker.io/v1/

2. If you Now check the .docker/config,json file, the previous entry for the geeklab user would be deleted.

# cat .docker/config.json
{
        "auths": {},
        "HttpHeaders": {
                "User-Agent": "Docker-Client/17.10.0-ce (linux)"
        }

3. Also, you would not find any information about the use in the “docker info” command.

# docker info | grep -i user

Filed Under: DevOps, Docker

Some more articles you might also be interested in …

  1. How to create Docker Image from a Container and Dockerfile
  2. How to Access Docker Container’s Network Namespace from Host
  3. EFS Mount Issue “Failed to resolve server: Name or service not known”
  4. Hello Newbies in Tech! Switching From Windows to Linux? Read This First
  5. How to add new host entry in /etc/hosts when a docker container is run
  6. Kubernetes Command Line Reference (Cheatsheet)
  7. How to Use External Python modules in MySQL Shell
  8. How to Build and push Docker Image to the Docker Hub Repository
  9. kubectl: command not found
  10. How to Trace Python Scripts using trace.py

You May Also Like

Primary Sidebar

Recent Posts

  • aws ec2: CLI for AWS EC2 (Command Examples)
  • aws cur – Create, query, and delete AWS usage report definitions (Command Examples)
  • aws configure – Manage configuration for the AWS CLI (Command Examples)
  • aws cognito-idp: Manage Amazon Cognito user pool and its users and groups using the CLI

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright