安装 Docker

我们按如下方式安装 Docker:

  1. 首先,删除之前安装的 Docker:
$ sudo apt-get remove docker docker-engine docker.io
  1. 安装必备软件:
$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common
  1. 添加 Docker 仓库的 GPG 密钥:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  1. 添加 Docker 仓库:
$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \  $(lsb_release -cs)  \ stable"
  1. 安装 Docker 社区版:
$ sudo apt-get update && sudo apt-get install docker-ce
  1. 安装成功完成后,将 Docker 添加为系统服务:
$ sudo systemctl enable docker
  1. 要以非 root 用户身份运行 Docker 或不使用sudo,请添加docker组:
$ sudo groupadd docker
  1. 将您的用户添加到docker组:
$ sudo usermod -aG docker $USER
  1. 现在注销并再次登录,以便组成员身份生效。登录后,运行以下命令来测试 Docker 安装:
$ docker run --name hello-world-container hello-world

您应该看到类似于以下内容的输出:

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Already exists 
Digest: sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c
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.
 (amd64)
 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:
 https://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

Docker 已成功安装。现在让我们为 TensorFlow 服务构建一个 Docker 镜像。

results matching ""

    No results matching ""