docker及容器設置開機自動啟動


環境:CentOS 7.6 參考docker容器怎么設置開機啟動

docker服務設置開機自動啟動

此方法適用於yum安裝的各種服務

查看已啟動的服務

systemctl list-units --type=service

已設置了開機自動啟動的服務

systemctl list-unit-files | grep enable

設置開機啟動

systemctl enable docker.service

移除開機啟動

systemctl disable docker.service

docker容器設置開機自動啟動

新容器

啟動時添加--restart=always參數

--restart的參數有
Flag	        Description
no		不自動重啟容器. (默認value)
on-failure 	容器發生error而退出(容器退出狀態不為0)重啟容器
unless-stopped 	在容器已經stop掉或Docker stoped/restarted的時候才重啟容器
always 	        在容器已經stop掉或Docker stoped/restarted的時候才重啟容器

已啟動的容器

docker update --restart=always 容器id或容器名


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM