【docker使用系列】docker 1.17安装和初步使用

参考资料

1.docker-ce 1.17的relase notes

https://docs.docker.com/v17.12/release-notes/docker-ce/

2.docker engine api

https://docs.docker.com/engine/api/v1.19/#21-containers

安装过程

yum install -y yum-utils device-mapper-persistent-data lvm2
yum install -y http://mirror.centos.org/centos/7/os/x86_64/Packages/libseccomp-2.3.1-3.el7.x86_64.rpm
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum-config-manager --enable docker-ce-edge
yum-config-manager --enable docker-ce-test
yum makecache fast
yum list docker-ce --showduplicates|sort -r
yum-config-manager --disable docker-ce-test
yum-config-manager --disable docker-ce-edge

配置过程

docker1.13.1之后的版本,和之前有很大的不同,有些参数都丢弃了,可以通过dockerd COMMAND –help

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
# 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 --storage-driver=devicemapper --exec-opt native.cgroupdriver=systemd -D --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

daemon.json

{
"data-root":"/data/docker",
"registry-mirror": [
"https://csokz3oi.mirror.aliyuncs.com"
],
"hosts": ["unix:///var/run/docker.sock","tcp://10.2.1.31:2375"]
}

启动和相关操作

启动命令:

systemctl daemon-reload
systemctl restart docker.service

api操作: