docker安装

一. docker在线安装
二. docker离线安装

一、docker在线安装

1、安装

yum install docker -y

2、启动

systemctl start docker

3、查看docker服务

systemctl status docker

4、配置docker镜像源(腾讯/阿里)

vim /etc/docker/daemon.json

添加以下内容:

{
"registry-mirrors": [
  "https://mirror.ccs.tencentyun.com"
]
}

5、重启

systemctl restart docker

二、docker离线安装

1、下载
下载地址: https://download.docker.com/linux/static/stable/x86_64/

linux下载命令:

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

2、上传并解压
上传docker-20.10.9.tgz到目录 /home/tmp

# 解压
tar -zxvf /home/tmp/docker-20.10.9.tgz 
上传后

3、进入docker目录复制所有文件到/usr/bin目录下,目的/user/bin是环境变量目录,在路径下都可以运行

cp /home/tmp/docker/* /usr/bin/

4、配置docker为服务

vim /etc/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
# 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=onfailure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target

5、添加权限

# 添加执行权限
chmod +x /etc/systemd/system/docker.service

# 重新加载
systemctl daemon-reload

# 开机启动
systemctl enable docker.service

# 启动
systemctl start docker
# 查看看状态
systemctl status docker

PS:添加软链接
问:为什么要添加软连接?
答: 符号链接的目的是:在不改变原目录/文件的前提下,起一个方便的别名! 软连接就相当于windows的快捷方式
用法: ln -s 源文件 目标文件,例如:

ln -s /usr/local/mysql/bin/mysql /usr/bin

这样我们就对/usr/bin目录下的mysql命令创建了软连接

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。