Article Directory
-
- 1. update apt
- 2. Update related dependencies and toolkits
- 3. Set the docker image source
- 4. Add Docker APT warehouse source
- 5. Update apt to ensure that the latest version of docker is installed later
- 6. Install the latest version of docker
- 7. Verify the running status of docker
- 8. Run the Hello world container
1. update apt
sudo apt update
Note: The execution results are as follows, "..." means to omit the content of the intermediate installation output, otherwise it will be too much
root@gt-ubuntu22-04-cmd-v1-0-32gb-100m:/home/ubuntu/ocr# sudo apt update
Get:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy InRelease [270 kB]
Get:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates InRelease [119 kB]
......
Get:48 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-security/multiverse amd64 c-n-f Metadata [260 B]
Fetched 28.7 MB in 4s (6687 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
233 packages can be upgraded. Run 'apt list --upgradable' to see them.
2. Update related dependencies and toolkits
sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
Note: The execution results are as follows, "..." means to omit the content of the intermediate installation output, otherwise it will be too much
root@gt-ubuntu22-04-cmd-v1-0-32gb-100m:/home/ubuntu/ocr# sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
dirmngr gnupg gnupg-l10n gnupg-utils gpg gpg-agent gpg-wks-client gpg-wks-server gpgconf gpgsm gpgv libcurl4
python3-software-properties
Suggested packages:
....................
No containers need to be restarted.
No user sessions are running outdated binaries.
No VM guests are running outdated hypervisor (qemu) binaries on this host.
3. Set the docker image source
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Note: OK means the setting is successful
root@gt-ubuntu22-04-cmd-v1-0-32gb-100m:/home/ubuntu/ocr# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
OK
4. Add Docker APT warehouse source
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Note: The execution results are as follows
root@gt-ubuntu22-04-cmd-v1-0-32gb-100m:/home/ubuntu/ocr# sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Repository: 'deb [arch=amd64] https://download.docker.com/linux/ubuntu jammy stable'
Description:
Archive for codename: jammy components: stable
More info: https://download.docker.com/linux/ubuntu
Adding repository.
Press [ENTER] to continue or Ctrl-c to cancel.sudo apt install docker-ce docker-ce-cli containerd.io
.........
apt install docker.io # version 20.10.21-0ubuntu1~22.04.3
apt install podman-docker # version 3.4.4+ds1-1ubuntu1.22.04.1
See 'snap info docker' for additional versions.
5. Update apt to ensure that the latest version of docker is installed later
sudo apt update
Note: The execution results are as follows
root@gt-ubuntu22-04-cmd-v1-0-32gb-100m:/home/ubuntu/ocr# sudo apt update
Hit:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy InRelease
Hit:2 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates InRelease
Hit:3 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-backports InRelease
Hit:4 https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-security InRelease
Hit:5 https://download.docker.com/linux/ubuntu jammy InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
217 packages can be upgraded. Run 'apt list --upgradable' to see them.
W: https://download.docker.com/linux/ubuntu/dists/jammy/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
6. Install the latest version of docker
sudo apt install docker-ce docker-ce-cli containerd.io
Note: When asked whether to continue, you need to enter "Y" to continue the installation
root@gt-ubuntu22-04-cmd-v1-0-32gb-100m:/home/ubuntu/ocr# sudo apt install docker-ce docker-ce-cli containerd.io
Reading package lists... Done
Building dependency tree... Done
......
Do you want to continue? [Y/n] y
......
No containers need to be restarted.
No user sessions are running outdated binaries.
No VM guests are running outdated hypervisor (qemu) binaries on this host.
7. Verify the running status of docker
sudo systemctl status docker
As follows, if you see "Active: active (running)", it means that docker is running. As long as the installation is complete, docker will automatically be running
root@gt-ubuntu22-04-cmd-v1-0-32gb-100m:/home/ubuntu/ocr# sudo systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2023-07-26 15:59:21 UTC; 56s ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 10753 (dockerd)
Tasks: 17
Memory: 27.0M
CPU: 619ms
CGroup: /system.slice/docker.service
└─10753 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
8. Run the Hello world container
docker container run hello-world
Seeing "Hello from Docker!" means the container ran successfully.
You can also use the "docker ps -a " command to view the existing containers, and you can see that a hello world container has been executed. (Note: This container is equivalent to exiting after outputting a line of commands, so here STATUS = Exited)
It's not easy to organize, give it a thumbs up!
It's not easy to organize, give it a thumbs up!
It's not easy to organize, give it a thumbs up!