Skip to main content

Docker Hub Tutorial - Login, Push Images & Access Token Setup

· 3 min read
Guangze Yang
R&D Researcher, Control & Robotics

Docker Hub is a cloud-based registry service for storing and sharing Docker images. This guide covers Docker Hub login, image pushing, and troubleshooting.

Docker Login​

Basic Login​

docker login

When you run this command, you'll be prompted to enter your username and password (or access token).

Error Troubleshooting​

If you encounter credential storage errors:

>> Error saving credentials: error storing credentials - err: exec: "docker-credential-desktop": executable file not found in $PATH, out: ``

Solution:

  1. Edit Docker configuration file:
sudo nano ~/.docker/config.json
  1. Change credsStore to credStore
Important

When editing the configuration file, ensure you maintain proper JSON syntax.

Using Access Tokens​

For improved security, we recommend using access tokens instead of passwords.

  1. Visit Docker Hub
  2. Navigate to My Account → Security → New Access Token
  3. Set token name and select required permissions
  4. Use the generated token in place of your password
Security Best Practices
  • Store access tokens in a secure location
  • Grant only minimum required permissions
  • Rotate tokens regularly

Pushing Images to Docker Hub​

1. Rename Container​

docker rename old_container_name_or_id new_container_name

2. Create Image from Container​

docker commit -a="<username>" -m="<commit message>" <container_id_or_name> <new_image_name>:<version>

Parameter explanation:

  • -a: Author name
  • -m: Commit message
  • <container_id_or_name>: Source container
  • <new_image_name>:<version>: New image name and tag

3. Tag Image​

Tag the image following Docker Hub naming convention <username>/<repository>:<TAG>:

docker tag <image_id> <username>/<repository>:<TAG>

Example:

docker tag myapp:latest youkoutaku/myapp:v1.0

4. Push to Docker Hub​

docker push <username>/<repository>:<TAG>

Example:

docker push youkoutaku/myapp:v1.0

Complete Workflow Example​

Here's a complete workflow for pushing a local container to Docker Hub:

# 1. Check current containers
docker ps -a

# 2. Create image from container
docker commit -a="youkoutaku" -m="Initial release" my_container myapp:latest

# 3. Tag for Docker Hub naming convention
docker tag myapp:latest youkoutaku/myapp:v1.0

# 4. Login to Docker Hub
docker login

# 5. Push image
docker push youkoutaku/myapp:v1.0

Troubleshooting​

Common Issues and Solutions​

  1. Authentication Error

    unauthorized: authentication required
    • Verify you're logged into Docker Hub
    • Check username and password/token are correct
  2. Naming Error

    denied: requested access to the resource is denied
    • Ensure image name follows <username>/<repository>:<tag> format
    • Verify you have owner permissions for the repository
  3. Network Error

    • Check internet connection
    • Verify proxy settings are correct