---
title: docker的安装
description: docker的安装
published: true
date: 2021-08-02T08:28:31.729Z
tags: docker
editor: markdown
dateCreated: 2021-08-02T07:22:52.894Z
---

# 安装Docker

## CentOS

#### 自动安装

```bash
$ curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
```

#### 手动安装

##### 卸载旧版本

```bash
$ sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine
```

##### 安装

###### 所需软件包

```bash
$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2
```

###### 设置仓库

阿里云

```bash
$ sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
```

###### 安装 Docker Engine-Community

```bash
$ yum install docker-ce docker-ce-cli containerd.io
```

#### 删除

##### 删除安装包

```bash
$ yum remove docker-ce
```

##### 删除镜像、容器、配置文件等

```bash
$ rm -rf /var/lib/docker
```