掌柜
手动安装docker
01/27
本文最后更新于2023年07月07日,已超过503天没有更新。如果文章内容或图片资源失效,请留言反馈,我会及时处理,谢谢!
配置宿主机网卡转发
## 若未配置,需要执行如下
[root@test:~]$ cat <<EOF > /etc/sysctl.d/docker.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward=1
EOF
[root@test:~]$ sysctl -p /etc/sysctl.d/docker.conf
sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-ip6tables: 没有那个文件或目录
sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-iptables: 没有那个文件或目录
net.ipv4.ip_forward = 1
# 由于在网卡配置了IPV6INIT=no,把ipv6关闭了,所以没有bridge-nf-call-ip6tables 那两个文件。
使用yum安装并配置docker
添加阿里源
# 下载阿里源 repo 文件
[root@test:~]$ curl -o /etc/yum.repos.d/Centos-7.repo http://mirrors.aliyun.com/repo/Centos-7.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2523 100 2523 0 0 8233 0 --:--:-- --:--:-- --:--:-- 8245
[root@test:~]$ curl -o /etc/yum.repos.d/docker-ce.repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2081 100 2081 0 0 46034 0 --:--:-- --:--:-- --:--:-- 46244
安装
[root@test:~]$ yum clean all && yum makecache
# yum 安装
[root@test:~]$ yum install docker-ce-20.10.6 -y
# 查看源中可用版本
[root@test:~]$ yum list docker-ce --showduplicates | sort -r
# 配置镜像加速源
[root@test:~]$ vim /etc/docker/daemon.json
{
"registry-mirrors" : [
"https://docker.mirrors.ustc.edu.cn"
]
}
# 设置开机自动启动
[root@test:~]$ systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@test:~]$ systemctl daemon-reload
# 启动 docker
[root@test:~]$ systemctl start docker
查看docker信息
[root@test:~]$ docker info
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Docker Buildx (Docker Inc., v0.7.1-docker)
scan: Docker Scan (Docker Inc., v0.12.0)
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 20.10.6
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
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 logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runtime.v1.linux runc io.containerd.runc.v2
Default Runtime: runc
Init Binary: docker-init
containerd version: 7b11cfaabd73bb80907dd23182b9347b4245eb5d
runc version: v1.0.2-0-g52b36a2
init version: de40ad0
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-1160.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 3.682GiB
Name: test.opstea.com
ID: GUXR:U62U:YLJK:IPC7:W3RM:5MNW:5ZLK:JTA3:BJVE:3UIO:YZJP:KFNR
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
https://docker.mirrors.ustc.edu.cn/
Live Restore Enabled: false
[root@test:~]$ which docker
/usr/bin/docker
[root@test:~]$
[root@test:~]$ ps -aux |grep docker
root 2242 0.1 1.9 659044 74096 ? Ssl 19:20 0:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
root 2411 0.0 0.0 112824 980 pts/0 S+ 19:22 0:00 grep --color=auto docker
[root@test:~]$ systemctl status containerd
● containerd.service - containerd container runtime
Loaded: loaded (/usr/lib/systemd/system/containerd.service; disabled; vendor preset: disabled)
Active: active (running) since 四 2022-01-27 19:20:52 CST; 2min 9s ago
Docs: https://containerd.io
Process: 2227 ExecStartPre=/sbin/modprobe overlay (code=exited, status=0/SUCCESS)
Main PID: 2232 (containerd)
Tasks: 8
Memory: 24.0M
CGroup: /system.slice/containerd.service
└─2232 /usr/bin/containerd
1月 27 19:20:52 test.opstea.com containerd[2232]: time="2022-01-27T19:20:52.923082432+08:00" level=info msg="loa...c.v1
1月 27 19:20:52 test.opstea.com containerd[2232]: time="2022-01-27T19:20:52.923089520+08:00" level=info msg="loa...l.v1
1月 27 19:20:52 test.opstea.com containerd[2232]: time="2022-01-27T19:20:52.923207799+08:00" level=info msg="loa...c.v1
1月 27 19:20:52 test.opstea.com containerd[2232]: time="2022-01-27T19:20:52.923224958+08:00" level=info msg="loa...c.v1
1月 27 19:20:52 test.opstea.com containerd[2232]: time="2022-01-27T19:20:52.923233516+08:00" level=info msg="loa...c.v1
1月 27 19:20:52 test.opstea.com containerd[2232]: time="2022-01-27T19:20:52.923240563+08:00" level=info msg="loa...c.v1
1月 27 19:20:52 test.opstea.com containerd[2232]: time="2022-01-27T19:20:52.923981730+08:00" level=info msg=serv...trpc
1月 27 19:20:52 test.opstea.com containerd[2232]: time="2022-01-27T19:20:52.924085995+08:00" level=info msg=serv...sock
1月 27 19:20:52 test.opstea.com containerd[2232]: time="2022-01-27T19:20:52.924517006+08:00" level=info msg="con...09s"
1月 27 19:20:52 test.opstea.com systemd[1]: Started containerd container runtime.
Hint: Some lines were ellipsized, use -l to show in full.
[root@test:~]$ systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since 四 2022-01-27 19:20:53 CST; 2min 17s ago
Docs: https://docs.docker.com
Main PID: 2242 (dockerd)
Tasks: 10
Memory: 44.7M
CGroup: /system.slice/docker.service
└─2242 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
1月 27 19:20:52 test.opstea.com dockerd[2242]: time="2022-01-27T19:20:52.997935619+08:00" level=info msg="ccRes...=grpc
1月 27 19:20:52 test.opstea.com dockerd[2242]: time="2022-01-27T19:20:52.997944088+08:00" level=info msg="Clien...=grpc
1月 27 19:20:53 test.opstea.com dockerd[2242]: time="2022-01-27T19:20:53.028039266+08:00" level=info msg="Loadi...art."
1月 27 19:20:53 test.opstea.com dockerd[2242]: time="2022-01-27T19:20:53.582619659+08:00" level=info msg="Defau...ress"
1月 27 19:20:53 test.opstea.com dockerd[2242]: time="2022-01-27T19:20:53.715572705+08:00" level=info msg="Firew...ning"
1月 27 19:20:53 test.opstea.com dockerd[2242]: time="2022-01-27T19:20:53.809912339+08:00" level=info msg="Loadi...one."
1月 27 19:20:53 test.opstea.com dockerd[2242]: time="2022-01-27T19:20:53.826353187+08:00" level=info msg="Docke....10.6
1月 27 19:20:53 test.opstea.com dockerd[2242]: time="2022-01-27T19:20:53.826498734+08:00" level=info msg="Daemo...tion"
1月 27 19:20:53 test.opstea.com systemd[1]: Started Docker Application Container Engine.
1月 27 19:20:53 test.opstea.com dockerd[2242]: time="2022-01-27T19:20:53.849185987+08:00" level=info msg="API l...sock"
Hint: Some lines were ellipsized, use -l to show in full.
[root@test:~]$