centos修改docker镜象存储与容器目录
centos修改docker镜象存储与容器目录
修改docker容器存储目录
vim /usr/lib/systemd/system/docker.service
修改如下:
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target rhel-push-plugin.socket registries.service
Wants=docker-storage-setup.service
Requires=docker-cleanup.timer
[Service]
Type=notify
NotifyAccess=all
EnvironmentFile=-/run/containers/registries.conf
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-storage
EnvironmentFile=-/etc/sysconfig/docker-network
Environment=GOTRACEBACK=crash
Environment=DOCKER_HTTP_HOST_COMPAT=1
Environment=PATH=/usr/libexec/docker:/usr/bin:/usr/sbin
ExecStart=/usr/bin/dockerd-current \
-g /mnt/docker \
--add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \
--default-runtime=docker-runc \
--exec-opt native.cgroupdriver=systemd \
--userland-proxy-path=/usr/libexec/docker/docker-proxy-current \
--init-path=/usr/libexec/docker/docker-init-current \
--seccomp-profile=/etc/docker/seccomp.json \
$OPTIONS \
$DOCKER_STORAGE_OPTIONS \
$DOCKER_NETWORK_OPTIONS \
$ADD_REGISTRY \
$BLOCK_REGISTRY \
$INSECURE_REGISTRY \
$REGISTRIES
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
TimeoutStartSec=0
Restart=on-abnormal
KillMode=process
[Install]
WantedBy=multi-user.target
保存后,重启docker
service docker restart
重启时提示需要更新systemctl
systemctl daemon-reload
添加docker国内镜像地址
vi /etc/docker/daemon.json
然后添加:
{
"registry-mirrors" : [
"http://xxx.m.daocloud.io",
"https://xxx.mirror.aliyuncs.com"
]
}
执行:
systemctl daemon-reload
service docker restart
ok….
将docker加入开机启动:
systemctl enable docker.service
安装docker-compose
安装
sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
授权
sudo chmod +x /usr/local/bin/docker-compose
可用
本来在很多操作系统里,/usr/local/bin目录下本来已经是全局环境变量里了,按理说应该在任何地方执行docker-compose命令都是可以的,可现实是:
看看系统变量有哪些目录是支持全局的:
echo $PATH
出来这个:
这个目录在全局变量里啊,不管了,那我把这个可执行文件软链到/usr/bin这个目录里吧,这个目录肯定可以的。
ln -s /usr/local/bin/docker-compose /usr/bin/
再执行:
ok了。。。。。