Centos8.1安装docker

IT
IT
IT
285
文章
1
评论
2020年6月13日15:03:52 评论 274 5470字阅读18分14秒

yum方式安装

  • 安装依赖
[root@lucky ~]# yum install -y yum-utils  device-mapper-persistent-data  lvm2
  • 添加仓库
[root@lucky ~]#  yum-config-manager  --add-repo   https://download.docker.com/linux/centos/docker-ce.repo
[root@iZrj987jhi4cl38mj8px0eZ ~]# dnf install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm
  • 安装最新版本的 Docker Engine-Community 和 containerd
[root@lucky ~]# yum install docker-ce docker-ce-cli  -y
  • 启动服务
[root@iZrj987jhi4cl38mj8px0eZ ~]# systemctl start docker
[root@iZrj987jhi4cl38mj8px0eZ ~]# systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
  • 配置镜像加速器
[root@iZrj987jhi4cl38mj8px0eZ ~]# sudo mkdir -p /etc/docker
[root@iZrj987jhi4cl38mj8px0eZ ~]# 
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://00s5k4m1.mirror.aliyuncs.com"]
}
EOF
[root@iZrj987jhi4cl38mj8px0eZ ~]# sudo systemctl daemon-reload
[root@iZrj987jhi4cl38mj8px0eZ ~]# sudo systemctl restart docker

RPM 安装

  • 下载docker-ce-cli
[root@iZrj987jhi4cl38mj8px0eZ ~]# wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-cli-19.03.9-3.el7.x86_64.rpm
[root@iZrj987jhi4cl38mj8px0eZ ~]# yum install docker-ce-cli-19.03.9-3.el7.x86_64.rpm -y
  • 下载docker
[root@iZrj987jhi4cl38mj8px0eZ ~]# wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-19.03.9-3.el7.x86_64.rpm
[root@iZrj987jhi4cl38mj8px0eZ ~]# dnf install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm
[root@iZrj987jhi4cl38mj8px0eZ ~]# yum install -y docker-ce-19.03.9-3.el7.x86_64.rpm
  • 启动服务
[root@iZrj987jhi4cl38mj8px0eZ ~]# systemctl start docker
[root@iZrj987jhi4cl38mj8px0eZ ~]# systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /usr/lib/systemd/system/docker.service.
  • 加速器
[root@iZrj987jhi4cl38mj8px0eZ ~]# sudo mkdir -p /etc/docker
[root@iZrj987jhi4cl38mj8px0eZ ~]# 
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://00s5k4m1.mirror.aliyuncs.com"]
}
EOF
[root@iZrj987jhi4cl38mj8px0eZ ~]# sudo systemctl daemon-reload
[root@iZrj987jhi4cl38mj8px0eZ ~]# sudo systemctl restart docker

二进制安装

[root@iZrj987jhi4cl38mj8px0eZ ~]# wget https://download.docker.com/linux/static/stable/x86_64/docker-19.03.9.tgz
[root@iZrj987jhi4cl38mj8px0eZ ~]# tar zxf docker-19.03.9.tgz 
[root@iZrj987jhi4cl38mj8px0eZ ~]#  cp -a docker/* /usr/bin/
[root@iZrj987jhi4cl38mj8px0eZ ~]#  chmod 755 /usr/bin/{containerd,containerd-shim,ctr,docker,dockerd,docker-init,docker-proxy,runc}
  • 创建docker的systemd unit文件
[root@iZrj987jhi4cl38mj8px0eZ ~]# vim /etc/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
 
[Service]
Type=notify
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
StartLimitBurst=3
StartLimitInterval=60s
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
Delegate=yes
KillMode=process
 
[Install]
WantedBy=multi-user.target
  • 启动
[root@iZrj987jhi4cl38mj8px0eZ ~]# systemctl daemon-reload
[root@iZrj987jhi4cl38mj8px0eZ ~]# systemctl start docker
[root@iZrj987jhi4cl38mj8px0eZ ~]# systemctl enable docker
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /etc/systemd/system/docker.service.
[root@iZrj987jhi4cl38mj8px0eZ ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/etc/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2020-06-13 16:34:56 CST; 12s ago
     Docs: https://docs.docker.com
 Main PID: 3093 (dockerd)
    Tasks: 18
   Memory: 30.9M
   CGroup: /system.slice/docker.service
           ├─3093 /usr/bin/dockerd
           └─3100 containerd --config /var/run/docker/containerd/containerd.toml --log-level info

6月 13 16:34:56 iZrj987jhi4cl38mj8px0eZ dockerd[3093]: time="2020-06-13T16:34:56.016942822+08:00" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
6月 13 16:34:56 iZrj987jhi4cl38mj8px0eZ dockerd[3093]: time="2020-06-13T16:34:56.087396381+08:00" level=warning msg="Your kernel does not support cgroup blkio weight"
6月 13 16:34:56 iZrj987jhi4cl38mj8px0eZ dockerd[3093]: time="2020-06-13T16:34:56.087429346+08:00" level=warning msg="Your kernel does not support cgroup blkio weight_device"
6月 13 16:34:56 iZrj987jhi4cl38mj8px0eZ dockerd[3093]: time="2020-06-13T16:34:56.087604192+08:00" level=info msg="Loading containers: start."
6月 13 16:34:56 iZrj987jhi4cl38mj8px0eZ dockerd[3093]: time="2020-06-13T16:34:56.335135110+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip >
6月 13 16:34:56 iZrj987jhi4cl38mj8px0eZ dockerd[3093]: time="2020-06-13T16:34:56.450708028+08:00" level=info msg="Loading containers: done."
6月 13 16:34:56 iZrj987jhi4cl38mj8px0eZ dockerd[3093]: time="2020-06-13T16:34:56.518093214+08:00" level=info msg="Docker daemon" commit=9d988398e7 graphdriver(s)=overlay2 version=19.03.9
6月 13 16:34:56 iZrj987jhi4cl38mj8px0eZ dockerd[3093]: time="2020-06-13T16:34:56.518515655+08:00" level=info msg="Daemon has completed initialization"
6月 13 16:34:56 iZrj987jhi4cl38mj8px0eZ dockerd[3093]: time="2020-06-13T16:34:56.557843966+08:00" level=info msg="API listen on /var/run/docker.sock"
6月 13 16:34:56 iZrj987jhi4cl38mj8px0eZ systemd[1]: Started Docker Application Container Engine.
  • 配置镜像加速
[root@iZrj987jhi4cl38mj8px0eZ ~]# sudo mkdir -p /etc/docker
[root@iZrj987jhi4cl38mj8px0eZ ~]# 
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://00s5k4m1.mirror.aliyuncs.com"]
}
EOF
[root@iZrj987jhi4cl38mj8px0eZ ~]# sudo systemctl daemon-reload
[root@iZrj987jhi4cl38mj8px0eZ ~]# sudo systemctl restart docker

Centos8.1安装docker

继续阅读
  • 我的QQ
  • QQ扫一扫
  • weinxin
  • 我的头条
  • 头条扫一扫
  • weinxin
IT
  • 本文由 发表于 2020年6月13日15:03:52
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
CentOS8.1系统安装 CentOS

CentOS8.1系统安装

CentOS8.1使用VM15进行安装 跳过第二行的检测,直接选择安装 选择语言 系统分区 选择自定义分区 选择标准分区,点击自动创建 分区的大小可以自己定义 选择安装模式 服务器建议安装最小版本,我...
Docker下载Centos镜像 Docker

Docker下载Centos镜像

默认情况下,直接下载的是官方最新的镜像 # docker pull centos 下载的镜像都是centos7.3或者最新的版本 我们想下载7.2或者更低版本怎么办? 打开下方连接 https://h...
Linux安装docker Docker

Linux安装docker

安装所需依赖包 yum install -y yum-utils \ device-mapper-persistent-data \ lvm2 安装yum源 yum-config-manager \ ...
docker安装mysql8.0 Docker

docker安装mysql8.0

创建存储目录 # mkdir -p /opt/data/mysql/data /opt/data/mysql/conf 基本使用 创建区分大小写文件 # cd /opt/data/mysql/conf...