docker安装

1、安装docker并配置镜像加速

1.1 Ubuntu安装docker

  • 安装一步一步的步骤我就不详细介绍了,网上自己搜索吧,我这里就写个简单脚本安装
    docker安装
    
    [root@jiangmin ~]#bash install_docker_ubuntu.sh
    Docker已安装,退出
    [root@jiangmin ~]#docker version
    Client: Docker Engine - Community
    Version:           19.03.5
    API version:       1.40
    Go version:        go1.12.12
    Git commit:        633a0ea838
    Built:             Wed Nov 13 07:29:52 2019
    OS/Arch:           linux/amd64
    Experimental:      false

Server: Docker Engine - Community
Engine:
Version: 19.03.5
API version: 1.40 (minimum version 1.12)
Go version: go1.12.12
Git commit: 633a0ea838
Built: Wed Nov 13 07:28:22 2019
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.9
GitCommit: e25210fe30a0a703442421b0f60afac609f950a3
runc:
Version: 1.0.1
GitCommit: v1.0.1-0-g4144b63
docker-init:
Version: 0.18.0
GitCommit: fec3683

#### 1.2 centos7安装docker
* 也写个简单脚本安装吧
![image.png](https://s2.51cto.com/images/20210803/1627980607255853.png?x-oss-process=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=)

[root@centos-7 ~]#bash install_docker_for_centos7.sh
[root@centos-7 ~]#docker version
Client: Docker Engine - Community
Version: 19.03.5
API version: 1.40
Go version: go1.12.12
Git commit: 633a0ea
Built: Wed Nov 13 07:25:41 2019
OS/Arch: linux/amd64
Experimental: false

Server: Docker Engine - Community
Engine:
Version: 19.03.5
API version: 1.40 (minimum version 1.12)
Go version: go1.12.12
Git commit: 633a0ea
Built: Wed Nov 13 07:24:18 2019
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.9
GitCommit: e25210fe30a0a703442421b0f60afac609f950a3
runc:
Version: 1.0.1
GitCommit: v1.0.1-0-g4144b63
docker-init:
Version: 0.18.0
GitCommit: fec3683

#### 1.3 centos8安装docker
这次我直接上代码,因为centos8跑docker,生产大概都不会用吧

[root@centos-8 ~]#cat install_docker_for_centos8.sh
#!/bin/bash
#
#****
#Author: jiangshen
#QQ: 1461918614
#Date: 2021-08-03
#FileName: install_docker_for_centos8.sh
#Description: The test script
#Copyright (C): 2021 All rights reserved
#****
. /etc/init.d/functions
COLOR="echo -e \E[1;32m"
END="\E[0m"
DOCKER_VERSION="-19.03.13-3.el8"
install_docker() {
${COLOR}"开始安装 Docker....."${END}
sleep 1
wget -P /etc/yum.repos.d/ https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo || { ${COLOR}" 互联网连接失败,请检查网络配置!"${END};exit; }
yum clean all
dnf -y install https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.13-3.1.el7.x86_64.rpm
yum -y install docker-ce$DOCKER_VERSION docker-ce-cli$DOCKER_VERSION || { ${COLOR}"Base,Extras的yum源失败,请检查yum源配置"${END};exit; }
mkdir -p /etc/docker
cat > /etc/docker/daemon.json <<EOF
{
"registry-mirrors": ["https://sfasfasfsa0hh.mirror.aliyuncs.com"] #注意我这里的镜像加速器是我乱写的哦,建议自己去阿里拿自己的。
}
EOF
systemctl enable --now docker
docker version && ${COLOR}"Docker安装成功"${END} || ${COLOR}"Docker安装失败"${END}
}
rpm -q docker &> /dev/null && action "Docker已安装" || install_docker

[root@centos-8 ~]#bash install_docker_for_centos8.sh
root@centos-8 ~]#docker version
Client: Docker Engine - Community
Version: 19.03.13
API version: 1.40
Go version: go1.13.15
Git commit: 4484c46d9d
Built: Wed Sep 16 17:02:36 2020
OS/Arch: linux/amd64
Experimental: false

Server: Docker Engine - Community
Engine:
Version: 19.03.13
API version: 1.40 (minimum version 1.12)
Go version: go1.13.15
Git commit: 4484c46d9d
Built: Wed Sep 16 17:01:11 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.2.13
GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683


#### 1.4 阿里镜像加速
注册登录阿里开发者社区
![image.png](https://s2.51cto.com/images/20210804/1628036870836277.png?x-oss-process=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=)
搜索容器镜像服务
![image.png](https://s2.51cto.com/images/20210803/1627981277896929.png?x-oss-process=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=)
点击镜像加速器
![image.png](https://s2.51cto.com/images/20210803/1627981470813689.png?x-oss-process=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=)
![image.png](https://s2.51cto.com/images/20210803/1627981556513666.png?x-oss-process=image/watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=)
上一篇:HDU7015 - Another String


下一篇:partial局部类