centos7搭建docker

老师要我们搭建一个deepo来运行深度学习的环境,我就开始入了docker的大坑。。。

------------------------------------------------------------------------------------------------------------------

简介

1、基于环境的要求,docker需要linux内核3.1以上,我就选择了centos7(centos7安装有问题的可以私聊)。

2、docker官网的安装链接。

点击打开链接

安装

1、推荐使用本地仓库安装

当第一次安装Docker CE在新的机器上之前,你需要安装Docker的仓库,然后你可以从仓库中安装和更新Docker。

1)安装必要的包。yum-utils提供了yum-config-manager实用程序,而devicemapper存储驱动程序需要设备device-mapper-persistent-data和lvm2。

$ sudo yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2
2)使用下面的命令来设置稳定的存储库。总是需要稳定的存储库,希望从edge或测试存储库安装构建。
$ sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

3)可选:启用edge和测试存储库。这些存储库包含在docker.repo文件中,但默认是禁用的。您可以在稳定的存储库旁边启用它们。

$ sudo yum-config-manager --enable docker-ce-edge

$ sudo yum-config-manager --enable docker-ce-test

2、docker的安装

1)安装最新版本的Docker CE,或进入下一个步骤安装特定版本。

$ sudo yum install docker-ce  
警告:如果启用了多个Docker存储库,在yum install或yum update命令中不指定版本,安装或更新将始终安装尽可能高的版本,这可能不适合稳定性需求。

2)在生产系统上,您应该安装一个特定版本的Docker CE,而不是总是使用最新版本。列出可用的版本。这个例子使用sort -r命令将结果按版本号排序,最高到最低,并被截断。

$ yum list docker-ce --showduplicates | sort -r  

注意:版本字符串是包名加上第一个连字符的版本。在上面的示例中,完全限定的包名是docker- 17.06.1.ce。

$ sudo yum install <FULLY-QUALIFIED-PACKAGE-NAME>

examp

。。

3)启动docker

$ sudo systemctl start docker

4)运行Holle world映像验证docker是否正确安装

$ sudo docker run hello-world

5)出现如下

Unable to find image 'hello-world:latest' locally
latest: Pulling from hello-world
535020c3e8ad: Pull complete 
af340544ed62: Pull complete 
Digest: sha256:a68868bfe696c00866942e8f5ca39e3e31b79c1e50feaee4ce5e28df2f051d5c
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 Hub account:
 https://hub.docker.com

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

说明可,Docker注册服务器从Docker Hub获取到最新的Hello World镜像,下载到了本地。可以再次运行Hello World镜像。

# docker run hello-world

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 Hub account:
 https://hub.docker.com

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

-------success

卸载

1)卸载 Docker 包

$ sudo yum remove docker-ce  

执行命令1)后,主机上的图像、容器、卷或自定义配置文件不会自动删除。使用下面的命令删除所有图像、容器和卷:

$ sudo rm -rf /var/lib/docker  

猜你喜欢

转载自blog.csdn.net/qq_35468937/article/details/79686906