安装 Docker

  1. 较旧的Docker版本称为dockerdocker-engine。如果已安装这些程序,请卸载它们以及相关的依赖项。
  $ sudo yum remove docker \
    docker-client \
    docker-client-latest \
    docker-common \
    docker-latest \
    docker-latest-logrotate \
    docker-logrotate \
  1. 安装 yum-utils 和 设置 Docker 存储库
$ sudo yum install -y yum-utils
$ sudo yum-config-manager \
    --add-repo \
  1. 安装 Docker 引擎
$ sudo yum install docker-ce docker-ce-cli containerd.io
  1. 启动 Docker 并设置开机自启动
$ sudo systemctl start docker
$ sudo systemctl enable docker
  1. 测试 Docker 是否可用
$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:8c5aeeb6a5f3ba4883347d3747a7249f491766ca1caa47e5da5dfcf6b9b717c0
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:

For more examples and ideas, visit:


安装 Docker Compose

在安装 Docker 之后可以选择安装一个 Docker Compose ,

$ sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose


$ sudo docker-compose -v
docker-compose version 1.27.4, build 40524192
# Linux  docker 


Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now