Docker Hub and Image Management
This guide walks you through the process of working with Docker Hub, building Docker images, tagging them, and managing different versions of your application.
Step 1: Download Node.js Code
First, download the Node.js code by clicking the button below:
Download Node.js CodeDocker Hub Login
Head to hub.docker.com and make sure you can log in.
Ensure you have your Docker Hub credentials ready for the next steps.
Add a Dockerfile
Follow these steps to add Docker files to your Node.js project:
Open Command Palette
Press Ctrl+Shift+P (Windows/Linux) or
Cmd+Shift+P (Mac) to open the command
palette.
Search for Docker Add
Type "Docker add" and select the option "Docker: Add Docker Files to Workspace..."
Select Application Platform
Choose Node.js since your application is written in Node.js.
Select Package.json Location
Select the root package.json file.
Enter Port Number
Enter 3000 as the port your application
runs
on.
Skip Docker Compose
When asked if you want to add a Docker Compose file, select "No".
The extension will generate two
Docker
files: .dockerignore and Dockerfile.
Build the Image
Build the Docker image with your Docker Hub username as the tag.
Explanation:
- docker build → Builds an image from a Dockerfile
- -t <YourRegistryName>/express:v1 → Tags the image with your username and version
- . → Build context (current directory)
Push the Image
Push the built image to Docker Hub.
Verification:
Back in hub.docker.com, locate the image you just pushed to verify it was uploaded successfully.
Pull the Image from Docker Hub
Let's first delete the local image and pull it back from Docker Hub to verify the process works.
Remove the local image:
Pull the image:
Purpose:
This step verifies that your image is correctly stored in Docker Hub and can be retrieved by you or others.
Create Version 2
Using the commands you learned earlier, build and push a new version to Docker Hub.
Build the v2 image:
Push the v2 image:
Verification:
Back in hub.docker.com, locate the v2 image you just pushed to verify both versions are available.
Cleanup
Remove the local images to clean up your system.
Remove the local v1 image:
Remove the local v2 image:
Note:
Your images remain safely stored in Docker Hub and can be pulled again anytime.
Delete Images from Docker Hub
If you need to remove images from your Docker Hub repository, follow these steps:
Method 1: Using Docker Hub Web Interface
- Log in to your Docker Hub account
- Navigate to your repositories from the top menu
- Click on the repository containing the image you want to delete
- Go to the "Tags" tab
- Check the boxes next to the tags you want to delete (v1, v2, etc.)
- Click the "Delete" button and confirm the action
Method 2: Using Docker CLI (Experimental)
Note: The Docker CLI currently doesn't support deleting images directly from Docker Hub. You must use the web interface.
However, you can delete local images using:
Important Considerations:
- Deleting images from Docker Hub is permanent and cannot be undone
- If other users or systems depend on these images, they will no longer be able to pull them
- Consider using private repositories if you need more control over image access