This lab guides you through pulling an image from Docker Hub and running it as a container. It is a simple exercise to familiarize you with Docker commands and the process of working with container images.
1# First ensure Docker is running
2docker info
3# Check if Docker is running and configured correctly
4docker version
5# List all images to verify the environment
6docker images
7$ docker images
8# REPOSITORY TAG IMAGE ID CREATED SIZE
9# hugomods/hugo exts-non-root eab3b744d003 6 weeks ago 807MB
10# ghcr.io/open-webui/open-webui main 09ef72fbc39c 2 months ago 5.05GB
11# curlimages/curl latest e507f3e43db3 3 months ago 21.9MB
12# hello-world
13#----- latest 74cc54e27dc4 5 months ago 10.1kB
14# Pull an image from Docker Hub
15docker pull hello-world
16# List all images to verify the pull
17# Using default tag: latest
18# latest: Pulling from library/hello-world
19# e6590344b1a5: Pull complete
20# Digest: sha256:ec153840d1e635ac434fab5e377081f17e0e15afab27beb3f726c3265039cfff
21# Status: Downloaded newer image for hello-world:latest
22# docker.io/library/hello-world:latest
23# docker images
24#-----
25# Run the image as a container
26docker run hello-world
27
28# Hello from Docker!
29# This message shows that your installation appears to be working correctly.
30#
31# To generate this message, Docker took the following steps:
32# 1. The Docker client contacted the Docker daemon.
33# 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
34# (amd64)
35# 3. The Docker daemon created a new container from that image which runs the
36# executable that produces the output you are currently reading.
37# 4. The Docker daemon streamed that output to the Docker client, which sent it
38# to your terminal.
39#
40# To try something more ambitious, you can run an Ubuntu container with:
41# $ docker run -it ubuntu bash
42
43# Share images, automate workflows, and more with a free Docker ID:
44# https://hub.docker.com/
45#
46# For more examples and ideas, visit:
47# https://docs.docker.com/get-started/
48#-----
49# Verify the container is running
50docker ps -a
51
52# CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
53# 5754af02a797 hello-world "/hello" 12 minutes ago Exited (0) 12 minutes ago distracted_noether
54# 7bf5fc1d8786 hugomods/hugo:exts-non-root "docker-entrypoint.s…" 24 hours ago Up 4 hours 0.0.0.0:1313->1313/tcp, [::]:1313->1313/tcp docker-with-hugo-server-1
55# 1df8e627f00a ghcr.io/open-webui/open-webui:main "bash start.sh" 2 months ago Up 44 hours (healthy) 0.0.0.0:3000->8080/tcp, [::]:3000->8080/tcp open-webui
56#----
57# Remove the container
58docker rm <container_id>
59docker rm 5754af
60# 5754af
61#----
62# Removing container does not remove the image
63docker images
64# REPOSITORY TAG IMAGE ID CREATED SIZE
65# hugomods/hugo exts-non-root eab3b744d003 6 weeks ago 807MB
66# ghcr.io/open-webui/open-webui main 09ef72fbc39c 2 months ago 5.05GB
67# curlimages/curl latest e507f3e43db3 3 months ago 21.9MB
68# hello-world latest 74cc54e27dc4 5 months ago 10.1kB
69
70#----
71#Remove the image
72docker rmi hello-world:latest
73# Untagged: hello-world:latest
74# Untagged: hello-world@sha256:ec153840d1e635ac434fab5e377081f17e0e15afab27beb3f726c3265039cfff
75# Deleted: sha256:74cc54e27dc41bb10dc4b2226072d469509f2f22f1a3ce74f4a59661a1d44602
76# Deleted: sha256:63a41026379f4391a306242eb0b9f26dc3550d863b7fdbb97d899f6eb89efe72
77# Verify the image is removed
78docker images
79# REPOSITORY TAG IMAGE ID CREATED SIZE
80# hugomods/hugo exts-non-root eab3b744d003 6 weeks ago 807MB
81# ghcr.io/open-webui/open-webui main 09ef72fbc39c 2 months ago 5.05GB
82# curlimages/curl latest e507f3e43db3 3 months ago 21.9MB