1 、dockerd & 啟動docker 后如何停止。
- 先找到dockerd 運行的pid
cat /etc/run/docker.pid
比如是pid是 123
kill -9 123
刪除文件
rm /etc/run/docker.pid
2、設(shè)置開機自動啟動
- 配置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-reloadsystemctl 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狀態(tài)退出時才從新啟動容器; always - 無論退出狀態(tài)是如何,都重啟容器;
- 最多重啟10次
sudo docker run --restart=on-failure:10 redis
4。防火墻
systemctl enable|disable firewalld #開機啟動
systemctl start|stop|restart firewalld #啟動、停止、重啟firewalld
5. enforce
臨時關(guān)閉:
[root@localhost ~] getenforce
Enforcing
[root@localhost ~] setenforce 0
[root@localhost ~] getenforce
Permissive
永久關(guān)閉:
[root@localhost ~] vim /etc/sysconfig/selinux
SELINUX=enforcing 改為 SELINUX=disabled
重啟服務(wù)reboot