一、環(huán)境準備
1臺虛擬機,系統(tǒng)為centos7
二、安裝 docker 17.09.0-ce
在?Docker17.03.0-ce?版本中,與在?Docker 1.12?中引入的實驗版本相比,管理插件?API發(fā)生了變化。
在升級到?Docker17.03.0-ce之前,必須卸載使用?Docker 1.12?安裝的插件,可通過?docker plugin rm?命令卸載插件。
如果有安裝舊版dokcer,先卸載
# ?yum ?-y remove docker*
#??yum ?-y remove ?container-selinux?
下載官方Docker YUM源,
在下載頁面選擇對應(yīng)的操作系統(tǒng)版本
https://www.docker.com/docker-community
https://docs.docker.com/install/linux/docker-ce/centos
#?yum ?-y ?install yum-utils
# ?yum-config-manager \
? ??--add-repo ?\
?https://download.docker.com/linux/centos/docker-ce.repo
# yum makecache fast
# ?yum list docker-ce.x86_64? --showduplicates |sort -r
#?yum -y ?install docker-ce-17.09.0.ce
#?systemctl start docker
# systemctl enable?docker
# systemctl status?docker
三、查看docker的啟動參數(shù)
我們來稍微了解下17.09.0.ce的啟動參數(shù)
# cat /usr/lib/systemd/system/docker.service
我們只要配置ExecStart這個對應(yīng)項,當使用systemctl start docker 的時候執(zhí)行。
Docker服務(wù)端默認不監(jiān)聽任何端口,客戶端通過?/var/run/docker.sock連接 docker daemon
詳細的配置參數(shù)可以使用?dockerd --help 查看
在沒有特殊要求的情況下,我們很多啟動配置參數(shù)是不需要用到,所以我把我自己的配置參數(shù)貼出來給大家看下。
########################
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd ?\
?--bip=172.18.0.1/16 \
-H tcp://0.0.0.0:5257 \
-H unix:///var/run/docker.sock \
--pidfile=/var/run/docker.pid
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
######################################
--bip ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?指定橋接地址,即定義一個容器的私有網(wǎng)絡(luò)?
--H tcp://0.0.0.0:5257 ? ? ? ? ? ? ? ? ? ? ? ? 將docker守護進程指定一個監(jiān)聽端口
--H unix:///var/run/docker.sock ? ? ? ? ? 將docker守護進程指定一個sock位置
--pidfile=/var/run/docker.pid ? ? ? ? ? ? ? 指定docker守護進程pid文件目錄
配置好上述的參數(shù)時候,我們就可以來啟動docker了
# systemctl stop docker
重新加載docker.service文件的配置,否則重啟也是啟動之前的配置
# systemctl daemon-reload
# systemctl start docker
四、參考
https://www.docker.com/docker-community