1. 更新yum镜像
可参考:https://www.pianshen.com/article/4728283652/
2. 安装gcc gcc++
sudo yum install gcc gcc-g++
3. 升级linux内核
sudo yum install kernel-devel kernel-doc kernel-header
4. 安装docker
查看docker-ce版本
(base) [[email protected] disk]# yum list docker-ce --showduplicates | sort -r
已加载插件:fastestmirror, langpacks
可安装的软件包
* updates: mirrors.aliyun.com
Loading mirror speeds from cached hostfile
* extras: mirrors.aliyun.com
docker-ce.x86_64 3:19.03.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:19.03.7-3.el7 docker-ce-stabl
安装指定版本
sudo yum install docker-ce-18.09.7 docker-ce-cli-18.09.7 containerd.io
启动docker
$ systemctl enable docker.service
$ systemctl start docker
验证docker安装是否成功
$ sudo docker run hello-world
如果成功了,会有如下内容
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535
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://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
5. 安装nvidia-docker
下载nvidia-docker离线安装包:
链接:https://pan.baidu.com/s/1boqVj28RDdXdm0O3KZQW0A
提取码:qp2g
sudo rpm -i nvidia-docker*.rpm
如果nvidia-docker启动异常(Permission denied),可能是selinux权限限制了,关闭selinux系统:
临时关闭:
永久关闭:
查询,selinux
[root/]# getenforce
Enforcing
[root /]#
永久关闭,查看文件 /etc/selinux/config
1
2 # This file controls the state of SELinux on the system.
3 # SELINUX= can take one of these three values:
4 # enforcing - SELinux security policy is enforced.
5 # permissive - SELinux prints warnings instead of enforcing.
6 # disabled - No SELinux policy is loaded.
7 SELINUX=enforcing
8 # SELINUXTYPE= can take one of three two values:
9 # targeted - Targeted processes are protected,
10 # minimum - Modification of targeted policy. Only selected processes are protected.
11 # mls - Multi Level Security protection.
12 SELINUXTYPE=targeted
13
保存后,重启。
6. 将docker目录指定放在比较大的磁盘
建议将docker目录指定放在比较大的磁盘,以备以后的扩展,不然后面迁移数据比较麻烦的。
参考:
解决Centos docker容器存放目录所在磁盘满了的问题
参考链接:
CentOS7安装 docker与nvidia-docker
centos7.6从零开始安装docker-ce和nvidia-docker
CentOS7安装 docker与nvidia-docker
Centos7下安装Docker(详细安装教程)
nvidia-docker 启动异常 Permission denied 已解决