26 0 0 0
#安装命令
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
#启动docker
systemctl start docker
#设置开机启动
systemctl enable docker
#创建存放文件夹
mkdir -p /datadisk/docker
#修改路径
vim /usr/lib/systemd/system/docker.service
将
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
修改为:
ExecStart=/usr/bin/dockerd --graph /datadisk/docker -H fd:// --containerd=/run/containerd/containerd.sock
#重启docker服务
systemctl daemon-reload
systemctl restart docker
#重新查看docker info
docker info|grep 'Docker Root Dir'
Docker Root Dir: /datadisk/docker
#验证
#下载一个redis镜像
docker pull redis
#查看sha256
# docker inspect -f {{".Id"}} redis
sha256:c33c9b2541a8fea04fe621e1e9d4e5973d9062f2a4eaac7a8d8b82c23c1b0aa8
#查看存储目录
ls -l /data/docker/image/overlay2/imagedb/content/sha256/
总用量 8
-rw------- 1 root root 6648 12月 31 17:25 c33c9b2541a8fea04fe621e1e9d4e5973d9062f2a4eaac7a8d8b82c23c1b0aa8
#修改配置
vim /etc/docker/daemon.json
#配置docker镜像仓库
{
"registry-mirrors": ["https://gx7o1moq.mirror.aliyuncs.com"]
}
#配置docker容器默认ip段
{
"debug" : true,
"default-address-pools" : [
{
"base" : "172.31.0.0/16",
"size" : 24
}
]
}
#配置docker容器日志大小
{
"log-driver":"json-file",
"log-opts": {
"max-size":"500m",
"max-file":"3"
}
}
#重启docker
systemctl daemon-reload
systemctl restart docker
docker rm -f 1e560fca3906
docker cp /www/runoob 96f7f14e99ab:/www/
docker cp 96f7f14e99ab:/www /tmp/
docker network inspect lss-net
docker network create -d bridge lss-net
docker network connect [网络] [容器]
docker network rm [网络]