文章目录
Linux环境下Docker的安装
一、使用yum 在线安装 Docker
提示:简要介绍离线安装和在线安装的两种方式:
1.查看是否安装docker
yum list installed | grep docker
2.安装docker
yum -y install docker
3 启动docker
systemctl start docker
4.查看docker服务状态
systemctl status docker
以上说明docker安装成功
二、离线安装方式
安装包官方地址:https://download.docker.com/linux/static/stable/x86_64/
1.创建下载目录
mkdir /usr/local/docker
cd /usr/local/docker
2.执行下载对应版本
wget https://download.docker.com/linux/static/stable/x86_64/docker-18.06.3-ce.tgz
3.解压文件
tar -zxvf docker-18.06.3-ce.tgz
4.将解压出来的docker文件复制到 /usr/bin/ 目录下
cp docker/* /usr/bin/
5.在/etc/systemd/system/目录下新增docker.service文件,这样可以将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 --selinux-enabled=false --insecure-registry=127.0.0.1
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
–insecure-registry=127.0.0.1(此处改成你私服ip)设置是针对有搭建了自己私服Harbor时允许docker进行不安全的访问,否则访问将会被拒绝。
5.给docker.service文件添加执行权限
chmod +x /etc/systemd/system/docker.service
6.重新加载配置文件
systemctl daemon-reload
7.启动,重启,查看docker指令
systemctl start docker
systemctl restart docker
systemctl status docker
8.设为开机启动
systemctl enable docker.service