淘先锋技术网

首页 1 2 3 4 5 6 7

一、安装docker(二进制方式)

1、下载docker二进制包

wget https://download.docker.com/linux/static/stable/x86_64/docker-19.03.14.tgz

2、添加执行权限并解压

tar -zxf docker-19.03.14.tgz && chmod +x docker/*

3、二进制文件放到/usr/bin下:mv docker/* /usr/bin/

4、创建docker配置文件

mkdir -p /etc/docker
vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://s1x5r8bz.mirror.aliyuncs.com"] 
} 

5、docker 被systemd管理

vim /usr/lib/systemd/system/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
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s

[Install]
WantedBy=multi-user.target

6、重新加载配置文件:

systemctl daemon-reload

7、启动并设为开机自启:

systemctl start docker && systemctl enable docker

8、查看版本:docker --version

二、安装docker-compose

1、使用github下载

curl -L https://github.com/docker/compose/releases/download/1.16.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

2、添加执行权限:

chmod +x /usr/local/bin/docker-compose

3、查看版本:

docker-compose -v 

三、升级docker-compose版本

1、查看docker-compose版本:docker-compose -v

2、下载并替换版本:

curl -L https://github.com/docker/compose/releases/download/1.27.4/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

3、添加替换文件的执行权限:

chmod +x /usr/local/bin/docker-compose

4、查看版本:docker-compose -v