mirror of
https://github.com/yeasy/docker_practice.git
synced 2024-12-26 15:06:18 +00:00
update
This commit is contained in:
parent
2b6e28d6a9
commit
a5b762c2ce
@ -1,23 +1,23 @@
|
||||
## Ubuntu 安装 Docker CE
|
||||
## Install Docker CE on Ubuntu
|
||||
|
||||
>警告:切勿在没有配置 Docker APT 源的情况下直接使用 apt 命令安装 Docker.
|
||||
>warning: Don't install Docker CE directly using apt without configuring Docker APT source.
|
||||
|
||||
### 准备工作
|
||||
### Preparation
|
||||
|
||||
#### 系统要求
|
||||
#### System requirements
|
||||
|
||||
Docker CE 支持以下版本的 [Ubuntu](https://www.ubuntu.com/server) 操作系统:
|
||||
Docker CE supports [Ubuntu](https://www.ubuntu.com/server) versions:
|
||||
|
||||
* Disco 19.04
|
||||
* Cosmic 18.10
|
||||
* Bionic 18.04 (LTS)
|
||||
* Xenial 16.04 (LTS)
|
||||
|
||||
Docker CE 可以安装在 64 位的 x86 平台或 ARM 平台上。Ubuntu 发行版中,LTS(Long-Term-Support)长期支持版本,会获得 5 年的升级维护支持,这样的版本会更稳定,因此在生产环境中推荐使用 LTS 版本。
|
||||
Docker CE can be installed on x86 platform or ARM. In Ubuntu distributions, LTS (Long-Term-Support) will get 5 years updating support, distributions like this will be stable. Therefore, LTS version is recommended in production environment.
|
||||
|
||||
#### 卸载旧版本
|
||||
#### Uninstall old version
|
||||
|
||||
旧版本的 Docker 称为 `docker` 或者 `docker-engine`,使用以下命令卸载旧版本:
|
||||
Old version of Docker is called `docker` or `docker-engine`. Use the following command to uninstall the old version:
|
||||
|
||||
```bash
|
||||
$ sudo apt-get remove docker \
|
||||
@ -25,9 +25,9 @@ $ sudo apt-get remove docker \
|
||||
docker.io
|
||||
```
|
||||
|
||||
### 使用 APT 安装
|
||||
### Use APT to install
|
||||
|
||||
由于 `apt` 源使用 HTTPS 以确保软件下载过程中不被篡改。因此,我们首先需要添加使用 HTTPS 传输的软件包以及 CA 证书。
|
||||
Because the `apt` source uses HTTPS to ensure that software downloads are not tampered with. Therefore, we need to add software packages and CA certificates that are transmitted using HTTPS first.
|
||||
|
||||
```bash
|
||||
$ sudo apt-get update
|
||||
@ -39,19 +39,19 @@ $ sudo apt-get install \
|
||||
software-properties-common
|
||||
```
|
||||
|
||||
鉴于国内网络问题,强烈建议使用国内源,官方源请在注释中查看。
|
||||
If you are in China, it is strongly recommended to use chinese sources. The official sources are in the comments.
|
||||
|
||||
为了确认所下载软件包的合法性,需要添加软件源的 `GPG` 密钥。
|
||||
In order to confirm the validity of the downloaded package, we need to add the `GPG` key of the software source.
|
||||
|
||||
```bash
|
||||
$ curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
|
||||
|
||||
|
||||
# 官方源
|
||||
# official
|
||||
# $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
||||
```
|
||||
|
||||
然后,我们需要向 `source.list` 中添加 Docker 软件源
|
||||
Then, we need to add Docker software source to `source.list`
|
||||
|
||||
```bash
|
||||
$ sudo add-apt-repository \
|
||||
@ -60,18 +60,18 @@ $ sudo add-apt-repository \
|
||||
stable"
|
||||
|
||||
|
||||
# 官方源
|
||||
# official
|
||||
# $ sudo add-apt-repository \
|
||||
# "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
|
||||
# $(lsb_release -cs) \
|
||||
# stable"
|
||||
```
|
||||
|
||||
>以上命令会添加稳定版本的 Docker CE APT 镜像源,如果需要测试或每日构建版本的 Docker CE 请将 stable 改为 test 或者 nightly。
|
||||
>The above commands will add stable Docker CE APT source. If you need test or nightly version of Docker, you can change the stable to test or nightly.
|
||||
|
||||
#### 安装 Docker CE
|
||||
#### Install Docker CE
|
||||
|
||||
更新 apt 软件包缓存,并安装 `docker-ce`:
|
||||
Update apt cache and install `docker-ce`:
|
||||
|
||||
```bash
|
||||
$ sudo apt-get update
|
||||
@ -79,43 +79,43 @@ $ sudo apt-get update
|
||||
$ sudo apt-get install docker-ce
|
||||
```
|
||||
|
||||
### 使用脚本自动安装
|
||||
### Auto install by script
|
||||
|
||||
在测试或开发环境中 Docker 官方为了简化安装流程,提供了一套便捷的安装脚本,Ubuntu 系统上可以使用这套脚本安装:
|
||||
Docker Offical has provided a set of convenient install scripts which can be installed on Ubuntu system for test or dev environments.
|
||||
|
||||
```bash
|
||||
$ curl -fsSL get.docker.com -o get-docker.sh
|
||||
$ sudo sh get-docker.sh --mirror Aliyun
|
||||
```
|
||||
|
||||
执行这个命令后,脚本就会自动的将一切准备工作做好,并且把 Docker CE 的 Edge 版本安装在系统中。
|
||||
Script will make everythings ok and install Edge version of Docker CE for system after this command.
|
||||
|
||||
### 启动 Docker CE
|
||||
### Launcher Docker CE
|
||||
|
||||
```bash
|
||||
$ sudo systemctl enable docker
|
||||
$ sudo systemctl start docker
|
||||
```
|
||||
|
||||
### 建立 docker 用户组
|
||||
### Add docker user group
|
||||
|
||||
默认情况下,`docker` 命令会使用 [Unix socket](https://en.wikipedia.org/wiki/Unix_domain_socket) 与 Docker 引擎通讯。而只有 `root` 用户和 `docker` 组的用户才可以访问 Docker 引擎的 Unix socket。出于安全考虑,一般 Linux 系统上不会直接使用 `root` 用户。因此,更好地做法是将需要使用 `docker` 的用户加入 `docker` 用户组。
|
||||
Command `docker` uses [Unix socket](https://en.wikipedia.org/wiki/Unix_domain_socket) to communicate with Docker engine default. Only users of `root` and `docker` groups can communicate Unix socket of Docker engine.`root` user is not directly used on Linux systems in general for security. Therefore, it is better to add users who need to use `docker` to the `docker` user group.
|
||||
|
||||
建立 `docker` 组:
|
||||
create `docker` group:
|
||||
|
||||
```bash
|
||||
$ sudo groupadd docker
|
||||
```
|
||||
|
||||
将当前用户加入 `docker` 组:
|
||||
add current user to `docker` group:
|
||||
|
||||
```bash
|
||||
$ sudo usermod -aG docker $USER
|
||||
```
|
||||
|
||||
退出当前终端并重新登录,进行如下测试。
|
||||
Exit current terminal and relogin to test.
|
||||
|
||||
### 测试 Docker 是否安装正确
|
||||
### Test whether Docker is installed correctly
|
||||
|
||||
```bash
|
||||
$ docker run hello-world
|
||||
@ -148,12 +148,12 @@ For more examples and ideas, visit:
|
||||
https://docs.docker.com/get-started/
|
||||
```
|
||||
|
||||
若能正常输出以上信息,则说明安装成功。
|
||||
If it shows above message, it means successful installation.
|
||||
|
||||
### 镜像加速
|
||||
### Registry Mirror(In China)
|
||||
|
||||
如果在使用过程中发现拉取 Docker 镜像十分缓慢,可以配置 Docker [国内镜像加速](mirror.md)。
|
||||
If you pull docker images very slowly, then you can configurate [Registry Mirror](mirror.md).
|
||||
|
||||
### 参考文档
|
||||
### Links
|
||||
|
||||
* [Docker 官方 Ubuntu 安装文档](https://docs.docker.com/install/linux/docker-ce/ubuntu/)
|
||||
* [Offical Docker Innstall Doc](https://docs.docker.com/install/linux/docker-ce/ubuntu/)
|
||||
|
Loading…
Reference in New Issue
Block a user