Centos 7 上安装 Docker CE 及 Nvidia Docker

Centos 7 上安装 Docker CE 及 Nvidia Docker

Centos 7 一键安装 Docker CE

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

yum remove -y docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
yum install -y yum-utils
yum-config-manager \
    --add-repo \

yum install -y docker-ce docker-ce-cli containerd.io
systemctl start docker
systemctl enable docker

Centos 7 修改 Docker CE 数据目录

如果数据盘较小,可以修改 Docker 的默认存储目录

修改 /usr/lib/systemd/system/docker.service ,在 ExecStart 后面添加 --graph=/data/docker/lib

Description=Docker Application Container Engine
After=network-online.target docker.socket firewalld.service containerd.service
Requires=docker.socket containerd.service

# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --graph=/data/docker/lib

然后重启 docker

systemctl daemon-reload
systemctl restart docker

在 Centos 7 上安装 Nvidia Docker

curl -s -L https://nvidia.github.io/nvidia-docker/centos7/x86_64/nvidia-docker.repo | sudo tee /etc/yum.repos.d/nvidia-docker.repo
yum install -y nvidia-docker2

nvidia-docker2Docker CE 配置文件与使用方法相同