Hello guys
How can i pass the -g option with the new docker for mac?
I want to change the default images folder too.
Thanks in advance.
Share and learn in the Docker community.
Hello guys
How can i pass the -g option with the new docker for mac?
I want to change the default images folder too.
Thanks in advance.
The -g option on Ubuntu 16.04 with docker-engine 1.12.1-0 from< official PPA is completely ignored:
Before docker-engine is even installed in /etc/default/docker:
DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4 -g /media/actionmystique/SAMSUNG-850-Ext4/Docker"
/var/lib/docker does not exist
/media/actionmystique/SAMSUNG-850-Ext4/Docker is empty
After installation without overwriting the /etc/default/docker file:
ll /var/lib/docker
drwx--x--x 10 root root 4096 Aug 28 14:58 ./
drwxr-xr-x 112 root root 4096 Aug 28 14:58 ../
drwx------ 5 root root 4096 Aug 28 14:58 aufs/
drwx------ 2 root root 4096 Aug 28 14:58 containers/
drwx------ 3 root root 4096 Aug 28 14:58 image/
drwxr-x--- 3 root root 4096 Aug 28 14:58 network/
drwx------ 2 root root 4096 Aug 28 14:58 swarm/
drwx------ 2 root root 4096 Aug 28 14:58 tmp/
drwx------ 2 root root 4096 Aug 28 14:58 trust/
drwx------ 2 root root 4096 Aug 28 14:58 volumes/
/media/actionmystique/SAMSUNG-850-Ext4/Docker is empty
Using the symlink is the way to go.
Also, the correct commands to control docker service are:
systemctl stop docker
install the symlink as explained by @nhazlett
systemctl start docker
systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2016-08-28 15:12:22 CEST; 7s ago
Docs: https://docs.docker.com
Main PID: 7097 (dockerd)
Tasks: 24
Memory: 17.5M
CPU: 429ms
CGroup: /system.slice/docker.service
├─7097 /usr/bin/dockerd -H fd://
└─7104 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --shim docker-containerd-shim --metrics-interval=0 --start-timeout 2m --st
Aug 28 15:12:22 samsung-ubuntu dockerd[7097]: time="2016-08-28T15:12:22.331839947+02:00" level=info msg="[graphdriver] using prior storage driver \"aufs\""
Aug 28 15:12:22 samsung-ubuntu dockerd[7097]: time="2016-08-28T15:12:22.341400411+02:00" level=info msg="Graph migration to content-addressability took 0.00 seconds"
Aug 28 15:12:22 samsung-ubuntu dockerd[7097]: time="2016-08-28T15:12:22.341959470+02:00" level=info msg="Loading containers: start."
Aug 28 15:12:22 samsung-ubuntu dockerd[7097]: time="2016-08-28T15:12:22.346940335+02:00" level=info msg="Firewalld running: false"
Aug 28 15:12:22 samsung-ubuntu dockerd[7097]: time="2016-08-28T15:12:22.587848771+02:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.22.0.0/1
Aug 28 15:12:22 samsung-ubuntu dockerd[7097]: time="2016-08-28T15:12:22.719073186+02:00" level=info msg="Loading containers: done."
Aug 28 15:12:22 samsung-ubuntu dockerd[7097]: time="2016-08-28T15:12:22.719141624+02:00" level=info msg="Daemon has completed initialization"
Aug 28 15:12:22 samsung-ubuntu dockerd[7097]: time="2016-08-28T15:12:22.719159156+02:00" level=info msg="Docker daemon" commit=23cf638 graphdriver=aufs version=1.12.1
Aug 28 15:12:22 samsung-ubuntu systemd[1]: Started Docker Application Container Engine.
Aug 28 15:12:22 samsung-ubuntu dockerd[7097]: time="2016-08-28T15:12:22.723875496+02:00" level=info msg="API listen on /var/run/docker.sock"
Ob Ubuntu 16.04 Server (64bit) I could successfully change the path by editing the
/etc/systemd/system/docker.service.d
like this
[Service]
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-storage
EnvironmentFile=-/etc/sysconfig/docker-network
ExecStart=
ExecStart=/usr/bin/docker daemon -H 0.0.0.0:2376 -H unix:///var/run/docker.sock $OPTIONS \
$DOCKER_STORAGE_OPTIONS \
$DOCKER_NETWORK_OPTIONS \
$BLOCK_REGISTRY \
--tlsverify \
--tlscacert=/etc/docker/cert/ca.pem \
--tlscert=/etc/docker/cert/server-cert.pem \
--tlskey=/etc/docker/cert/server-key.pem \
-g /data/docker
Added the line with -g
(and don’t forget the ’ ’ in the line before).
I did both options on a VPS with an sshfs storage vps connected as the image location. I keep getting an error when doing “docker pull ubuntu” -> failed to register layer: Error processing tar file(exit status 1): lchown /bin/dnsdomainname: no such file or directory
Anyone know how to deal with this?
Check this
I have followed instructions in Runtime directory and storage driver on Ubuntu 16.04.1:
mkdir /etc/systemd/system/docker.service.d
create some drop-in.conf file in /etc/systemd/system/docker.service.d , e.g. docker-overlay.conf
add these lines into drop-in file, replace “/mnt/docker-data” with your new docker data location:
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd --graph="/mnt/docker-data" --storage-driver=overlay
sudo systemctl daemon-reload
sudo systemctl restart docker
Those on 16.04 see comment by @thaJeztah https://github.com/docker/docker/issues/3127
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;
https://docs.docker.com/engine/reference/commandline/daemon/#daemon-configuration-file
E.g
I’m on Ubuntu 16.04.1, but it shouldn’t matter because this is a cross-distro solution.
Just put this json into /etc/docker/daemon.json:
{
“graph”: “/path/to/docker”
}
Worked for me and I didn’t have to mess with upstart or systemd.
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.
Thanks, that’s worked for me, on Fedora 25
Thanks!
Works for docker raspberry pi 3, debian jessie running docker version 17.03.0-ce
Hi,
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’
Best
That works, thanks!!!
For anyone browsing this page in the future looking for a shell script to move/change the docker root directory on Ubuntu (tested with 16.04), you can download it directly move-docker-root.sh or visit my site https://sysinfo.io/ubuntu-16-04-move-docker-root/.
#!/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.
For newer versions you would need to have a look here: https://stackoverflow.com/a/34731550/164374
Here is the content of “etc/docker/daemon.json”
{
"graph": "/mnt/docker"
}
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.
Have created a separate topic. appreciate your help . https://forums.docker.com/t/docker-engine-is-not-starting/40698
I’ve used “data-root” instead, I think because the docker version… tks!
Thanks! This works perfectly on ubuntu 16.04.3.