docker 安装

安装docker

yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum list docker-ce.x86_64 --showduplicates | sort -r
yum -y install docker-ce-17.12.1.ce-1.el7.centos

docker version
systemctl enable docker
systemctl start docker
systemctl status docker

3、修改配置文件

mkdir -p /data/docker

vim /etc/docker/daemon.json
{
“registry-mirrors”: [“https://934du3yi.mirror.aliyuncs.com”],
“data-root”: “/data/docker”,
“log-driver”: “json-file”,
“log-opts”: {
“max-size”: “400m”,
“max-file”: “5”
}
}
4、重启dockersystemctl restart docker
rm -rf /var/lib/docker 默认安装路径,不推荐安装在/var/lib目录下(20G太小)
docker info 查看/data/docker是否生效

5、给prod用户添加docker权限

sudo su -
sudo groupadd docker
sudo gpasswd -a prod docker
sudo systemctl restart docker
suprod
docker info
docker修改datadir

docker images 查看IMAGE ID

docker ps -a 查看正在运行的任务

systemctl stop docker

cp -R /var/lib/docker /data/docker/

vim /etc/docker/daemon.json
{
“registry-mirrors”: [“https://934du3yi.mirror.aliyuncs.com”],
“experimental”: true,
“storage-driver”: “overlay2”,
“data-root”: “/data/docker”,
“storage-opts”: [
“overlay2.override_kernel_check=true”
],
“log-driver”: “json-file”,
“log-opts”: {
“max-size”: “3000m”,
“max-file”: “7”
},
“runtimes”: {
“nvidia”: {
“path”: “nvidia-container-runtime”,
“runtimeArgs”: []
}
}
}
docker start 51535d9b4146 184998d82a17

systemctl start docker

docker info 查看dir是否已修改

你可能感兴趣的:(linux,docker)