安装docker

安装docker

yum安装docker

安装所需软件包

[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data lvm2

配置阿里源

[root@localhost ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

安装docker

[root@localhost ~]# yum -y install docker-ce docker-ce-cli containerd.io

启动docker,并设置开机自启

[root@localhost ~]# systemctl start docker && systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

安装docker-compose

下载docker-compose包

docker-compose官方下载https://github.com/docker/compose/releases

[root@localhost ~]# sudo curl -L "https://github.com/docker/compose/releases/download/v2.2.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

赋权,创建软连接

[root@localhost ~]# chmod +x /usr/local/bin/docker-compose 
[root@localhost ~]# ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

查看版本

[root@localhost ~]# docker-compose -v
Docker Compose version v2.2.2

离线安装docker

下载docker的离线包

官方网站:https://download.docker.com/linux/static/stable/x86_64/

最新版下载链接:https://download.docker.com/linux/static/stable/x86_64/docker-20.10.13.tgz

[root@localhost ~]# ll
total 594424
-rw-------. 1 root root      1260 May  7  2021 anaconda-ks.cfg
-rw-r--r--  1 root root  60730088 Oct 12 05:00 docker-20.10.13.tgz

解压docker包

[root@localhost ~]# tar -zxf docker-20.10.13.tgz -C /opt/

安装docker

[root@localhost ~]# cp -rf /opt/docker/* /usr/bin/

将docker写入服务中

cat >> /etc/systemd/system/docker.service << EOF
[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
EOF

设置docker开机自启

[root@localhost ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /etc/systemd/system/docker.service.

离线安装docker-compose

将在官网提前下载好的安装包上传到服务器

[root@localhost ~]# ll
total 673972
-rw-r--r--  1 root root  17176256 Oct 12 05:00 docker-compose-linux-x86_64

赋权,创建软连接

[root@localhost ~]# mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
[root@localhost ~]# chmod +x /usr/local/bin/docker-compose 
[root@localhost ~]# ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

查看版本

[root@localhost ~]# docker-compose -v
Docker Compose version v2.2.2
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值