It’s also possible to use a daemon.json configuration file instead of /etc/default/docker. The /etc/default/docker is only used for systems running upstart, and not for systems running systemd, so is more portable. Also it allows reloading some configuration settings without restarting the daemon;
I want to do this centos7, could anyone please suggest me how to achieve this? I am using centos 7 and latest docker version 1.13. I have mounted a storage drive /dev/sdb and i want the docker to use this drive instead of /var/lib/docker.
Modifying the docker.service.d might be a problem when updating the packages.
for Centos, you should modify:
/etc/sysconfig/docker
OPTIONS=’–selinux-enabled --log-driver=journald --signature-verification=false -g /new/path/to/docker’
#!/bin/bash
#sysinfo.io
#change paths below to suit your needs
dockerdir_new='/docker/var/'
dockerdir_old='/var/lib/docker/'
set -e
dockerdir_new2=$(echo "$dockerdir_new" | sed 's/\//\\\//g')
systemctl stop docker
mkdir -p $dockerdir_new
rsync -a $dockerdir_old* $dockerdir_new
sed -i.bak "/ExecStart=\/usr\/bin\/dockerd \-H fd:\/\//c ExecStart=\/usr\/bin\/dockerd \-H fd:\/\/ -g ${dockerdir_new2}" /lib/systemd/system/docker.service
mv $dockerdir_old /var/lib/docker.bak/
ln -s $dockerdir_new /var/lib/docker
systemctl daemon-reload
systemctl start docker.service
printf '\n* The Docker systemd config has been backed up to /lib/systemd/system/docker.service.bak\n* A backup of the old Docker Root has been copied to /var/lib/docker.bak/\n\n'
docker info | grep 'Root Dir'
You’re welcome. Took me all day dealing with sed’s delimiter escapes. I’m sure there is a more proficient scripter out there who may want to improve on my script, but hey, it works great.
Mine is rhel . The solution worked for me.
I restarted my aws instance then I face the below error when I start docker service.
Job for docker.service failed because the control process exited with error code. See “systemctl status docker.service” and “journalctl -xe” for details.
Has someone find this error after moving the Docker folder?
[root@dgdalecfg201 docker]# docker run hello-world
Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/: x509: certificate signed by unknown authority.
See 'docker run --help'.
The problem was that the admin from this servers changed the domain or something like that, what I did to fix this was run this command: sudo update-ca-trust This was the fix on CentOS.