1 、dockerd & 启动docker 后如何停止。
- 先找到dockerd 运行的pid
cat /etc/run/docker.pid
比如是pid是 123
kill -9 123
删除文件
rm /etc/run/docker.pid
2、设置开机自动启动
- 配置service
vi /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start docker.service
-
systemctl enable docker.service
#自动启动- 输出如下
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service。
- 输出如下
- 检验
# ps aux|grep docker
root 2262 0.1 4.4 472948 44944 ? Ssl 16:38 0:00 /usr/bin/dockerd
root 2266 0.2 1.3 277032 13540 ? Ssl 16:38 0:01 docker-containerd --config /var/run/docker/containerd/containerd.toml
root 2895 0.0 0.0 112660 972 pts/0 S+ 16:48 0:00 grep --color=auto docker
3 docker 容器自动重启
docker update --restart=always xxx
no - 容器退出时,不重启容器; on-failure - 只有在非0状态退出时才从新启动容器; always - 无论退出状态是如何,都重启容器;
- 最多重启10次
sudo docker run --restart=on-failure:10 redis
4。防火墙
systemctl enable|disable firewalld
#开机启动
systemctl start|stop|restart firewalld
#启动、停止、重启firewalld
5. enforce
临时关闭:
[root@localhost ~] getenforce
Enforcing
[root@localhost ~] setenforce 0
[root@localhost ~] getenforce
Permissive
永久关闭:
[root@localhost ~] vim /etc/sysconfig/selinux
SELINUX=enforcing 改为 SELINUX=disabled
重启服务reboot