關於Docker的介紹,也很多。我文筆也不好。也不拷貝別人的成果了。
後續DevOps工具鏈基本都是基於Docker容器進行創建的。這裏先寫一下Docker的安裝。以後安裝Docker只需要拷貝三個文件,然後賦執行權限,然後執行腳本即可
我就寫一下,我自己平常怎麼操作
安裝腳本 installDocker.sh :
#!/bin/bash
echo "start install docker"
tar -xvf ./docker-18.06.1-ce.tgz
cp docker/* /usr/bin/
cp docker.service /etc/systemd/system/docker.service
chmod +x /etc/systemd/system/docker.service
echo "install complete"
echo "run docker"
systemctl daemon-reload
systemctl start docker
echo "docker run success"
echo "set auto enable"
systemctl enable docker.service
docker -v
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
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
將這兩個文件保存到和Docker安裝同一級目錄下。然後給安裝腳本賦予執行權限:
chmod +x installDocker.sh
執行腳本
./installDocker.sh
看到
Docker version 18.06.1-ce, build e68fc7a
即代表安裝成功。
docker pull
docker run
docker save
docker images