【Docker 安装教程】CentOS 7.5安装Docker

安装教程(推荐):

  1. 查看Linux内核版本(内核版本需要高于3.10):
    uname -r
  2. 更新yum源:
    sudo yum update
  3. 卸载旧版本:
    sudo yum remove docker docker-common docker-selinux docker-engine
  4. 依赖包安装:
    sudo yum install -y yum-utils device-mapper-persistent-data lvm2
  5. 添加yum源:
    sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  6. 查看版本库:
    yum list docker-ce --showduplicates | sort -r
  7. 安装docker:
    sudo yum install docker-ce
  8. 开机启动:
    sudo systemctl enable docker
  9. 启动docker:
    sudo systemctl start docker
  10. 查看本版:
    docker version
  11. 测试容器:
    docker run hello-world

官方安装教程:

1.卸载旧版本:

sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

2.安装依赖:

sudo yum install -y yum-utils

3.配置镜像仓库:

sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
    # http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo 推荐使用阿里云镜像仓库

4.安装docker:

sudo yum install docker-ce docker-ce-cli containerd.io

5.启动docker:

sudo systemctl start docker

6.运行容器:

sudo docker run hello-world

7.卸载docker:

sudo yum remove docker-ce docker-ce-cli containerd.io

8.删除缓存文件:

sudo rm -rf /var/lib/docker

官方文档

配置镜像加速器(阿里云为例):

#1.
sudo mkdir -p /etc/docker

#2.
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://5c1hla0z.mirror.aliyuncs.com"]
}
EOF

#3.
sudo systemctl daemon-reload

#4.
sudo systemctl restart docker

你可能感兴趣的:(Docker)