Refers: Install Docker Engine on Ubuntu
root@OCLT71159526:~# dpkg -l | grep "ca-certificates\|curl"
ii ca-certificates 20230311ubuntu0.22.04.1 all Common CA certificates
ii curl 7.81.0-1ubuntu1.15 amd64 command line tool for transferring data with URL syntax
ii libcurl3-gnutls:amd64 7.81.0-1ubuntu1.15 amd64 easy-to-use client-side URL transfer library (GnuTLS flavour)
ii libcurl4:amd64 7.81.0-1ubuntu1.15 amd64 easy-to-use client-side URL transfer library (OpenSSL flavour)
root@OCLT71159526:~# ls -l /etc/apt/keyrings/docker.asc
ls: cannot access '/etc/apt/keyrings/docker.asc': No such file or directory
root@OCLT71159526:~# curl --fail --silent --show-error --location https://download.docker.com/linux/ubuntu/gpg --output /etc/apt/keyrings/docker.asc
root@OCLT71159526:~# ls -l /etc/apt/keyrings/docker.asc
-rw-r--r-- 1 root root 3817 Feb 29 12:19 /etc/apt/keyrings/docker.asc
root@OCLT71159526:~# echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
root@OCLT71159526:~# ls -l /etc/apt/sources.list.d/docker.list
-rw-r--r-- 1 root root 131 Feb 29 12:24 /etc/apt/sources.list.d/docker.list
root@OCLT71159526:~# cat /etc/apt/sources.list.d/docker.list
deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu noble stable
root@OCLT71159526:~# apt-get update
Hit:1 http://archive.ubuntu.com/ubuntu noble InRelease
Ign:2 https://download.docker.com/linux/ubuntu noble InRelease
Hit:3 http://archive.ubuntu.com/ubuntu noble-updates InRelease
Hit:4 http://security.ubuntu.com/ubuntu noble-security InRelease
Hit:5 http://archive.ubuntu.com/ubuntu noble-backports InRelease
Ign:2 https://download.docker.com/linux/ubuntu noble InRelease
Ign:2 https://download.docker.com/linux/ubuntu noble InRelease
Err:2 https://download.docker.com/linux/ubuntu noble InRelease
Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown.
Could not handshake: Error in the certificate verification. [IP: 172.21.132.58 8080]
Reading package lists... Done
W: Failed to fetch https://download.docker.com/linux/ubuntu/dists/noble/InRelease
Certificate verification failed: The certificate is NOT trusted. The certificate issuer is unknown.
Could not handshake: Error in the certificate verification. [IP: 172.21.132.58 8080]
W: Some index files failed to download. They have been ignored, or old ones used instead.
root@OCLT71159526:~# vi /etc/apt/apt.conf.d/99verify-peer.conf
::
::
root@OCLT71159526:~# cat /etc/apt/apt.conf.d/99verify-peer.conf
Acquire { https::Verify-Peer false }
root@OCLT71159526:~# apt-get update
Hit:1 http://security.ubuntu.com/ubuntu noble-security InRelease
Get:2 https://download.docker.com/linux/ubuntu noble InRelease [48.8 kB]
Hit:3 http://archive.ubuntu.com/ubuntu noble InRelease
Get:4 https://download.docker.com/linux/ubuntu noble/stable amd64 Packages [26.8 kB]
Get:5 https://download.docker.com/linux/ubuntu noble/stable amd64 Contents (deb) [1342 B]
Hit:6 http://archive.ubuntu.com/ubuntu noble-updates InRelease
Hit:7 http://archive.ubuntu.com/ubuntu noble-backports InRelease
Fetched 77.0 kB in 1s (111 kB/s)
Reading package lists... Done
root@OCLT71159526:~# which docker
(.....nothing!)
root@OCLT71159526:~# apt-get install --yes docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
dbus-user-session docker-ce-rootless-extras libltdl7 libslirp0 pigz slirp4netns
Suggested packages:
aufs-tools cgroupfs-mount | cgroup-lite
The following NEW packages will be installed:
containerd.io dbus-user-session docker-buildx-plugin docker-ce docker-ce-cli docker-ce-rootless-extras
docker-compose-plugin libltdl7 libslirp0 pigz slirp4netns
0 upgraded, 11 newly installed, 0 to remove and 0 not upgraded.
Need to get 117 MB of archives.
After this operation, 420 MB of additional disk space will be used.
Get:1 https://download.docker.com/linux/ubuntu noble/stable amd64 containerd.io amd64 1.6.28-1 [29.6 MB]
Get:2 http://archive.ubuntu.com/ubuntu noble/universe amd64 pigz amd64 2.6-1 [63.6 kB]
::
::
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.6) ...
/sbin/ldconfig.real: /usr/lib/wsl/lib/libcuda.so.1 is not a symbolic link
root@OCLT71159526:~# which docker
/usr/bin/docker
root@OCLT71159526:~# docker --version
Docker version 27.0.3, build 7d4bcd8
root@OCLT71159526:~# ls -ld /etc/containerd /etc/docker
drwxr-xr-x 2 root root 4096 Feb 29 12:55 /etc/containerd
drwxr-xr-x 2 root root 4096 Feb 6 16:13 /etc/docker
root@OCLT71159526:~# ps -ef | grep "[d]ockerd\|[c]ontainerd"
root 10319 1 0 12:55 ? 00:00:00 /usr/bin/containerd
root 10455 1 0 12:55 ? 00:00:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
root@OCLT71159526:~# systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2024-02-29 12:55:09 EST; 3min 8s ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 10455 (dockerd)
Tasks: 17
Memory: 36.1M
CGroup: /system.slice/docker.service
└─10455 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Feb 29 12:55:09 OCLT71159526 dockerd[10455]: time="2024-02-29T12:55:09.699508533-05:00" level=info msg="Loading containers: start."
Feb 29 12:55:09 OCLT71159526 dockerd[10455]: time="2024-02-29T12:55:09.874405538-05:00" level=info msg="Loading containers: done."
::
::
Feb 29 12:55:09 OCLT71159526 dockerd[10455]: time="2024-02-29T12:55:09.943489236-05:00" level=info msg="API listen on /run/docker.sock"
Feb 29 12:55:09 OCLT71159526 systemd[1]: Started Docker Application Container Engine.
root@OCLT71159526:~# systemctl status containerd.service
● containerd.service - containerd container runtime
Loaded: loaded (/lib/systemd/system/containerd.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2024-02-29 12:55:08 EST; 3min 29s ago
Docs: https://containerd.io
Main PID: 10319 (containerd)
Tasks: 15
Memory: 19.5M
CGroup: /system.slice/containerd.service
└─10319 /usr/bin/containerd
::
::
Feb 29 12:55:08 OCLT71159526 containerd[10319]: time="2024-02-29T12:55:08.677893026-05:00" level=info msg=serving... address=/run/containerd/containerd.sock
Feb 29 12:55:08 OCLT71159526 containerd[10319]: time="2024-02-29T12:55:08.677928664-05:00" level=info msg="containerd successfully booted in 0.025408s"
Feb 29 12:55:08 OCLT71159526 systemd[1]: Started containerd container runtime.
root@OCLT71159526:~# ifconfig docker0
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:00:22:67:72 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
To enable executing the docker command without sudo (optional):
root@OCLT71159526:~# grep docker /etc/group
docker:x:989:
root@OCLT71159526:~# id -a kaau
uid=1000(kaau) gid=1000(kaau) groups=1000(kaau),4(adm),20(dialout),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),116(netdev)
root@OCLT71159526:~# usermod --append --groups docker kaau
root@OCLT71159526:~# id -a kaau
uid=1000(kaau) gid=1000(kaau) groups=1000(kaau),4(adm),20(dialout),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),116(netdev),989(docker)
root@OCLT71159526:~# su - kaau
kaau@OCLT71159526:~$ groups
kaau adm dialout cdrom floppy sudo audio dip video plugdev netdev docker
kaau@OCLT71159526:~$ exit
logout
#
# kaau logout and login again, else could not access /var/run/docker.socket
#
kaau@OCLT71159526:~$ docker --help
Usage: docker [OPTIONS] COMMAND
A self-sufficient runtime for containers
Common Commands:
run Create and run a new container from an image
exec Execute a command in a running container
ps List containers
build Build an image from a Dockerfile
::
::
Run 'docker COMMAND --help' for more information on a command.
For more help on how to use Docker, head to https://docs.docker.com/go/guides/
kaau@OCLT71159526:~$ docker info
Client: Docker Engine - Community
Version: 25.0.3
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.12.1
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.24.6
Path: /usr/libexec/docker/cli-plugins/docker-compose
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 25.0.3
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
runc version: v1.1.12-0-g51d5e94
init version: de40ad0
Security Options:
seccomp
Profile: builtin
Kernel Version: 5.15.133.1-microsoft-standard-WSL2
Operating System: Ubuntu 22.04.4 LTS
OSType: linux
Architecture: x86_64
CPUs: 24
Total Memory: 15.47GiB
Name: OCLT71159526
ID: 10fc846e-c512-46a9-97bd-7dd99dc8bc28
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support
#
# Run:
#
kaau@OCLT71159526:~$ docker run --interactive --tty ubuntu bash
Unable to find image 'ubuntu:latest' locally
docker: Error response from daemon: Get "https://registry-1.docker.io/v2/":
net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
See 'docker run --help'.
kaau@OCLT71159526:~$ ls -l ${HOME}/.docker
ls: cannot access '/home/kaau/.docker': No such file or directory
kaau@OCLT71159526:~$ mkdir ${HOME}/.docker
kaau@OCLT71159526:~$ vi ${HOME}/.docker/config.json
::
::
kaau@OCLT71159526:~$ cat ${HOME}/.docker/config.json | jq
{
"proxies": {
"default": {
"httpProxy": "http://localhost:3128",
"httpsProxy": "https://localhost:3128",
"noProxy": "*.test.example.com,.example.org,127.0.0.0/8"
}
}
}
kaau@OCLT71159526:~$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete
Digest: sha256:d000bc569937abbe195e20322a0bde6b2922d805332fd6d8a68b19f524b7d21d
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
kaau@OCLT71159526:~$ docker ps --all
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f251dbd4fbe0 hello-world "/hello" 9 seconds ago Exited (0) 8 seconds ago vibrant_bardeen
kaau@OCLT71159526 ~ $ docker image list
i Info → U In Use
IMAGE ID DISK USAGE CONTENT SIZE EXTRA
hello-world:latest f9078146db2e 25.9kB 9.49kB U
kaau@OCLT71159526:~$ docker run --interactive --tty ubuntu bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
01007420e9b0: Pull complete
Digest: sha256:f9d633ff6640178c2d0525017174a688e2c1aef28f0a0130b26bd5554491f0da
Status: Downloaded newer image for ubuntu:latest
root@853d7aa5826e:/# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=24.04
DISTRIB_CODENAME=noble
DISTRIB_DESCRIPTION="Ubuntu 24.04.4 LTS"
[CTRL-p] [CTRL-q] to exit..... ---gracefully exit, container is still running
root@853d7aa5826e:/#
kaau@OCLT71159526:~$ docker ps --all
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
853d7aa5826e ubuntu "bash" 49 seconds ago Up 48 seconds optimistic_williamson
f251dbd4fbe0 hello-world "/hello" 2 minutes ago Exited (0) 2 minutes ago vibrant_bardeen
kaau@OCLT71159526:~$ docker attach optimistic_williamson
root@853d7aa5826e:/# exit ---container killed
exit
kaau@OCLT71159526:~$ docker ps --all
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
853d7aa5826e ubuntu "bash" About a minute ago Exited (0) 2 seconds ago optimistic_williamson
f251dbd4fbe0 hello-world "/hello" 3 minutes ago Exited (0) 33 seconds ago vibrant_bardeen
kaau@OCLT71159526 ~ $ docker image list
i Info → U In Use
IMAGE ID DISK USAGE CONTENT SIZE EXTRA
hello-world:latest f9078146db2e 25.9kB 9.49kB
ubuntu:latest 84e77dee7d1b 119MB 31.7MB
#
# clean up:
#
kaau@OCLT71159526:~$ docker rm vibrant_bardeen
vibrant_bardeen
kaau@OCLT71159526:~$ docker rm optimistic_williamson
optimistic_williamson
kaau@OCLT71159526 ~ $ docker rmi hello-world:latest
Untagged: hello-world:latest
Deleted: sha256:d000bc569937abbe195e20322a0bde6b2922d805332fd6d8a68b19f524b7d21d
kaau@OCLT71159526 ~ $ docker rmi ubuntu:latest
Untagged: ubuntu:latest
Deleted: sha256:f9d633ff6640178c2d0525017174a688e2c1aef28f0a0130b26bd5554491f0da