@[toc]
1. 離線一鍵部署(推薦)
包含:
1) docker v1.19
2)docker-compose v1.24.0適用環(huán)境
centos 7
Ubuntu 18 +下載地址
>>> CSDN 下載連接
-
安裝方式
執(zhí)行部署包中的compose_install.sh
腳本即可谆扎。
2. 阿里云yum源安裝
2.1 卸載舊版
# yum remove docker \
docker-common \
docker-selinux \
docker-engine
有得文檔上選擇卸載組件比較多:
# yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
2.2 安裝依賴包
# yum install -y yum-utils device-mapper-persistent-data lvm2
2.3 yum源
2.3.1 添加yum源
# yum-config-manager \
--add-repo \
https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
2.3.2 更新yum源
說明:非必要
yum-config-manager --enable docker-ce-edge
2.4 安裝
1)清除緩存
yum makecache fast
2)安裝
# yum install docker-ce -y
2.5 啟動(dòng)和添加開機(jī)啟動(dòng)項(xiàng)
(略)
3. 官方源安裝(擇版本選擇)
3.1 卸載老版本的Docker
說明:同上
3.2 官方y(tǒng)um源
說明:要啟用哪個(gè)版本的源就將其下的enable值設(shè)置為1
# cat /etc/yum.repos.d/docker-ce.repo
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-stable-debuginfo]
name=Docker CE Stable - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/stable
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-stable-source]
name=Docker CE Stable - Sources
baseurl=https://download.docker.com/linux/centos/7/source/stable
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-edge]
name=Docker CE Edge - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/edge
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-edge-debuginfo]
name=Docker CE Edge - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/edge
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-edge-source]
name=Docker CE Edge - Sources
baseurl=https://download.docker.com/linux/centos/7/source/edge
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-test]
name=Docker CE Test - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-test-debuginfo]
name=Docker CE Test - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-test-source]
name=Docker CE Test - Sources
baseurl=https://download.docker.com/linux/centos/7/source/test
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-nightly]
name=Docker CE Nightly - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-nightly-debuginfo]
name=Docker CE Nightly - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-nightly-source]
name=Docker CE Nightly - Sources
baseurl=https://download.docker.com/linux/centos/7/source/nightly
enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
3.3 查看可用版本
# yum list docker-ce --showduplicates|grep "^doc"|sort -r
docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.3.ce-1.el7 docker-ce-stable
docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable
3.4 安裝指定版本
說明:以docker-ce-18.06.0.ce-3.el7為例
# yum -y install docker-ce-18.06.0.ce-3.el7
3.5 啟動(dòng)docker 設(shè)置開機(jī)啟動(dòng)
(略)
4. 其他離線安裝方式
4.1 rpm安裝
安裝包
附件“離線安裝包”目錄中安裝
# rpm -vih docker-ce-selinux-17.03.3.ce-1.el7.noarch.rpm
# rpm -vih docker-ce-17.03.3.ce-1.el7.x86_64.rpm4.rpm
- 啟動(dòng)并設(shè)置開機(jī)啟動(dòng)(略)
4.2 yum 安裝
準(zhǔn)備好yum用的rpm包裕坊,拷貝到服務(wù)器,執(zhí)行
yum localinstall *.rpm
4.3 二進(jìn)制文件安裝
官網(wǎng)下載
https://download.docker.com/linux/static/stable/x86_64/解壓縮
tar xf docker-xxxxx.tgz
- 拷貝二進(jìn)制文件
cp docker/* /usr/bin/
- docker注冊(cè)為server
創(chuàng)建 /etc/systemd/system/docker.service
文件內(nèi)容如下:
[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
- 給執(zhí)行權(quán)限
chmod +x /etc/systemd/system/docker.service
systemctl daemon-reload
- 啟動(dòng)并設(shè)置開機(jī)啟動(dòng)
(略)