环境:Ubuntu 20.04 目的:安装docker、启动服务 依据: 官方文档 |
sudo su
apt remove docker docker-engine docker.io containerd runc
输入命令
lsb_release -a
打印返回
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.6 LTS
Release: 20.04
Codename: focal
apt -y install ca-certificates curl gnupg lsb-release
输入命令
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
打印返回(返回OK即为成功)
OK
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
apt -y install docker-ce docker-ce-cli containerd.io
systemctl start docker
输入命令
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-11-29 19:21:17 PST; 1min 51s ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 58743 (dockerd)
Tasks: 10
Memory: 24.9M
CGroup: /system.slice/docker.service
└─58743 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Nov 29 19:21:16 vac-virtual-machine systemd[1]: Starting Docker Application Container Engine...
Nov 29 19:21:16 vac-virtual-machine dockerd[58743]: time="2023-11-29T19:21:16.897970864-08:00" level=info msg="Starting up"
Nov 29 19:21:16 vac-virtual-machine dockerd[58743]: time="2023-11-29T19:21:16.899753412-08:00" level=info msg="detected 127.0.0.53 nameserver, assuming systemd-resolved, >
Nov 29 19:21:17 vac-virtual-machine dockerd[58743]: time="2023-11-29T19:21:17.036608569-08:00" level=info msg="Loading containers: start."
Nov 29 19:21:17 vac-virtual-machine dockerd[58743]: time="2023-11-29T19:21:17.497580306-08:00" level=info msg="Loading containers: done."
Nov 29 19:21:17 vac-virtual-machine dockerd[58743]: time="2023-11-29T19:21:17.566831721-08:00" level=info msg="Docker daemon" commit=311b9ff graphdriver=overlay2 version=>
Nov 29 19:21:17 vac-virtual-machine dockerd[58743]: time="2023-11-29T19:21:17.567026727-08:00" level=info msg="Daemon has completed initialization"
Nov 29 19:21:17 vac-virtual-machine systemd[1]: Started Docker Application Container Engine.
Nov 29 19:21:17 vac-virtual-machine dockerd[58743]: time="2023-11-29T19:21:17.636911780-08:00" level=info msg="API listen on /run/docker.sock"
输入命令
docker version
打印返回
Client: Docker Engine - Community
Version: 24.0.7
API version: 1.43
Go version: go1.20.10
Git commit: afdd53b
Built: Thu Oct 26 09:08:01 2023
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 24.0.7
API version: 1.43 (minimum version 1.12)
Go version: go1.20.10
Git commit: 311b9ff
Built: Thu Oct 26 09:08:01 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.25
GitCommit: d8f198a4ed8892c764191ef7b3b06d8a2eeb5c7f
runc:
Version: 1.1.10
GitCommit: v1.1.10-0-g18a0cb0
docker-init:
Version: 0.19.0
GitCommit: de40ad0
避免每次使用Docker时都需要使用sudo(默认情况下,只有root用户和docker组的用户才能运行Docker命令)
sudo usermod -aG docker $USER
service docker restart