sudo apt update
注:执行结果如下,“…”表示省略中间安装输出的内容,不然太多了
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.
sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
注:执行结果如下,“…”表示省略中间安装输出的内容,不然太多了
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.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
注:出现OK表示设置成功
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
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
注:执行结果如下
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.
sudo apt update
注:执行结果如下
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.
sudo apt install docker-ce docker-ce-cli containerd.io
注:当询问是否继续时,需要输入“Y”,才可以继续安装
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.
sudo systemctl status docker
如下,看到“Active: active (running)”则表示docker正在运行,只要安装完,docker自动就是运行的状态
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
docker container run hello-world
看到“Hello from Docker!”则表示容器运行成功。
还可通过“docker ps -a ”命令,查看当前已有的容器有哪些,可以看到有一个hello world容器已执行过。(注:这个容器相当于是输出一行命令后就退出了,所以这里的STATUS = Exited)
整理不易,点个赞吧!
整理不易,点个赞吧!
整理不易,点个赞吧!