多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# 安装 Docker 我们按如下方式安装 Docker: 1. 首先,删除之前安装的 Docker: ```py $ sudo apt-get remove docker docker-engine docker.io ``` 1. 安装必备软件: ```py $ sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ software-properties-common ``` 1. 添加 Docker 仓库的 GPG 密钥: ```py $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - ``` 1. 添加 Docker 仓库: ```py $ sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable" ``` 1. 安装 Docker 社区版: ```py $ sudo apt-get update && sudo apt-get install docker-ce ``` 1. 安装成功完成后,将 Docker 添加为系统服务: ```py $ sudo systemctl enable docker ``` 1. 要以非 root 用户身份运行 Docker 或不使用`sudo`,请添加`docker`组: ```py $ sudo groupadd docker ``` 1. 将您的用户添加到`docker`组: ```py $ sudo usermod -aG docker $USER ``` 1. 现在注销并再次登录,以便组成员身份生效。登录后,运行以下命令来测试 Docker 安装: ```py $ docker run --name hello-world-container hello-world ``` 您应该看到类似于以下内容的输出: ```py 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 镜像。