Docker is a powerful tool for building, running, and sharing containerized applications. In this lab, we’ll walk through a complete hands-on experience: from running your first container to building and publishing your own Node.js app container on Google Artifact Registry.
By the end of this lab, you’ll be able to:
- Run Docker containers
- Build a custom Docker image
- Debug running containers
- Push and pull Docker images using Google Artifact Registry
🧠 New to containers? Before diving into the lab, check out this beginner-friendly guide to container technology — it covers the history, the tools, and why Docker became the standard.
Prerequisites
- Basic understanding of command-line tools
- A Google Cloud account with billing enabled
- Familiarity with Cloud Shell is helpful but not mandatory
Lab Setup
Activate your Google Cloud Shell (click the terminal icon in the top-right corner of the console). This will launch a temporary VM where Docker and Google Cloud CLI are pre-installed.

Make sure Docker is working:
docker run hello-world
Task 1: Run Your First Docker Container
Let’s get familiar with Docker using the official hello-world image.
docker run hello-world
This command pulls the image from Docker Hub (if not already present) and prints a message. Run it again:
docker run hello-world
Now it should run directly from your local image cache.
Check existing containers:
docker ps -a
Task 2: Build a Docker Image
Create a simple Node.js app inside a folder:
mkdir ~/docker-lab && cd ~/docker-lab
Create the app:
cat > app.js <<EOF
const http = require('http');
const server = http.createServer((req, res) => {
res.writeHead(200);
res.end('Hello World');
});
server.listen(80);
EOF
Now write a Dockerfile:
cat > Dockerfile <<EOF
FROM node:lts
WORKDIR /app
ADD . /app
EXPOSE 80
CMD ["node", "app.js"]
EOF
Build your image:
docker build -t node-app:0.1 .
Verify the image:
docker images
Task 3: Run and Test Your Application
Run your container and map port 4000 on your local host to port 80 in the container:
docker run -p 4000:80 --name my-app node-app:0.1
Open a second Cloud Shell tab and test it:
curl http://localhost:4000
Output: Hello World
Stop and remove the container:
docker stop my-app && docker rm my-app
Run it in the background this time:
docker run -p 4000:80 --name my-app -d node-app:0.1
Task 4: Debugging Containers
To check container logs:
docker logs my-app
To open an interactive shell inside:
docker exec -it my-app bash
Inside the container:
ls
exit
Get detailed metadata:
docker inspect my-app
Or extract just the container’s IP:
docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' my-app
Task 5: Push to Google Artifact Registry
Create the registry:
gcloud artifacts repositories create my-repository \
--repository-format=docker \
--location=us-east1 \
--description="My Docker repo"
Authenticate Docker with Artifact Registry:
gcloud auth configure-docker us-east1-docker.pkg.dev
Tag and build the image:
docker build -t us-east1-docker.pkg.dev/$(gcloud config get-value project)/my-repository/node-app:0.2 .
Push it:
docker push us-east1-docker.pkg.dev/$(gcloud config get-value project)/my-repository/node-app:0.2
Remove local images to simulate a fresh environment:
docker stop $(docker ps -q)
docker rm $(docker ps -aq)
docker rmi -f $(docker images -aq)
Pull and run the image:
docker run -p 4000:80 -d us-east1-docker.pkg.dev/$(gcloud config get-value project)/my-repository/node-app:0.2
curl http://localhost:4000
Conclusion
In this lab, you learned how to:
- Run Docker containers
- Build a Node.js container from scratch
- Use debugging techniques
- Push and pull images from Google Artifact Registry
Docker enables fast, reliable, and consistent application deployment across environments. Stay tuned for the next lab where we’ll use these containers with Kubernetes!
Want more labs like this?
📬 Subscribe here to get new DevOps and Cloud labs, guides, and learning resources straight to your inbox.