DEV Community

janak0ff
janak0ff

Posted on

Pull Docker Image

Nautilus project developers are planning to start testing on a new project. As per their meeting with the DevOps team, they want to test containerized environment application features. As per details shared with DevOps team, we need to accomplish the following task:

a. Pull busybox:musl image on App Server 2 in Stratos DC and re-tag (create new tag) this image as busybox:news.


Step-by-Step Instructions

1. SSH into Application Server 2

ssh steve@stapp02
Enter fullscreen mode Exit fullscreen mode

Password: Am3ric@


2. Switch to root or use sudo

sudo su -
Enter fullscreen mode Exit fullscreen mode

or prefix all commands with sudo


3. Pull the Docker image

Pull the busybox:musl image from Docker Hub:

sudo docker pull busybox:musl
Enter fullscreen mode Exit fullscreen mode

4. Verify the image was pulled successfully

sudo docker images | grep busybox
Enter fullscreen mode Exit fullscreen mode

Or specifically:

sudo docker images busybox:musl
Enter fullscreen mode Exit fullscreen mode

5. Retag the image

Create a new tag busybox:news for the existing image:

sudo docker tag busybox:musl busybox:news
Enter fullscreen mode Exit fullscreen mode

6. Verify the new tag was created

sudo docker images | grep busybox
Enter fullscreen mode Exit fullscreen mode

You should see both busybox:musl and busybox:news with the same IMAGE ID.


7. Confirm both tags point to the same image (optional)

# Get image ID of original
sudo docker images busybox:musl -q

# Get image ID of new tag
sudo docker images busybox:news -q

# Both should show the same ID
Enter fullscreen mode Exit fullscreen mode

Complete Execution Summary

# SSH to App Server 2
ssh steve@stapp02

# Switch to root
sudo su -

# Pull the image
docker pull busybox:musl

# Verify pull
docker images busybox:musl

# Retag the image
docker tag busybox:musl busybox:news

# Verify both tags
docker images | grep busybox

# Confirm same image ID
echo "Original ID: $(docker images busybox:musl -q)"
echo "New ID: $(docker images busybox:news -q)"
Enter fullscreen mode Exit fullscreen mode

Verification Script

Run this to verify everything is correct:

echo "=== Pulling busybox:musl image ==="
docker pull busybox:musl

echo -e "\n=== Verifying image was pulled ==="
docker images busybox:musl

echo -e "\n=== Retagging as busybox:news ==="
docker tag busybox:musl busybox:news

echo -e "\n=== All busybox images ==="
docker images | grep busybox

echo -e "\n=== Comparing image IDs ==="
ORIGINAL_ID=$(docker images busybox:musl -q)
NEW_ID=$(docker images busybox:news -q)

if [ "$ORIGINAL_ID" = "$NEW_ID" ]; then
    echo "✅ Both tags point to the same image ID: $ORIGINAL_ID"
    echo "✅ Task completed successfully!"
else
    echo "❌ Image IDs do not match!"
fi

echo -e "\n=== Full image details ==="
docker images --format "table {{.Repository}}:{{.Tag}}\t{{.ID}}\t{{.Size}}" | grep busybox
Enter fullscreen mode Exit fullscreen mode

Important Notes

  • Retagging does NOT create a new image; it just adds another tag to the same image
  • The image ID remains the same for both tags
  • Both tags refer to the same underlying layers
  • This is useful for versioning or creating aliases for images

Understanding BusyBox

BusyBox is a software suite that provides several stripped-down Unix tools in a single executable file. It's commonly used in minimal Docker images.

  • busybox:musl uses the musl libc (a lightweight C standard library)
  • busybox:glibc uses the glibc (GNU C library)
  • busybox:latest typically uses glibc

If You Want to Remove the Original Tag (Optional)

After retagging, you can keep both tags or remove the original:

# Remove the original tag (only if you want to)
docker rmi busybox:musl

# Note: This only removes the tag, not the image
# The image remains as long as it has at least one tag (busybox:news)
Enter fullscreen mode Exit fullscreen mode

Quick One-Liner

sudo docker pull busybox:musl && sudo docker tag busybox:musl busybox:news && sudo docker images | grep busybox
Enter fullscreen mode Exit fullscreen mode

Troubleshooting

If the image fails to pull:

# Check Docker daemon status
systemctl status docker

# Check network connectivity
ping -c 3 registry-1.docker.io

# Try pulling with verbose output
docker pull busybox:musl --debug
Enter fullscreen mode Exit fullscreen mode

If you get a permission error:

# Use sudo
sudo docker pull busybox:musl
sudo docker tag busybox:musl busybox:news
Enter fullscreen mode Exit fullscreen mode

If the tag already exists and you want to overwrite:

Docker automatically overwrites existing tags, so just run the command again.

To see all tags for an image:

docker images --filter=reference='busybox:*'
Enter fullscreen mode Exit fullscreen mode

Top comments (0)