Reputation: 117
We are trying to figure out how to change the target place of the docker container. By default it is created in /var/lib/docker/containers. Lets say I would like to move it to /tmp/docker. All I could find so far was the docker volumes but it is not doing the thing the purpose of this usage is different.
What we want to do is to place the container in the RAM memory of the server so we can significantly reduce the time spent for building binaries.
Is it possible?
Regards, Jordan
Upvotes: 5
Views: 8376
Reputation: 6759
There appears to be a -g command line option, I don't really understand why it is called graph...
It has been deprecated and renamed to --data-root.
--data-root /var/lib/docker Path to use as the root of the Docker runtime
https://docs.docker.com/reference/commandline/cli/
mkdir /tmp/docker && docker --data-root /var/lib/docker /tmp/docker ...
Upvotes: 5
Reputation: 2179
See 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
:
{
"data-root": "/path/to/docker"
}
For the older versions it was "graph" option:
{
"graph": "/path/to/docker"
}
Worked for me and I didn't have to mess with upstart or systemd.
Upvotes: 9
Reputation: 31
We tried the following steps to Docket container folder to different folder:
Stop Docker service
chkconfig docker off
reboot the server
copy files /var/lib/docker to /targetfolder/docker using rsync -a --sparse --progress /var/lib/docker /apps/docker
Edit Configuration : /lib/systemd/system/docker.service ExecStart=/usr/bin/dockerd -g /targetfolder/docker/
mv /var/lib/docker /var/lib/docker1 (for backup)
ln -s /targetfolder/docker /var/lib/docker (optional - )
7.chkconfig docker on
8.systemctl daemon-reload
9.systemctl restart docker
Upvotes: 3
Reputation: 7
Stop docker service:
service docker stop
Move your containers folder to your ssd:
mv /var/lib/docker/containers /mnt/ssd_example/
Create symlink to default docker container folder:
ln -s /mnt/ssd_example/containers/ /var/lib/docker/containers
Start docker service:
service docker start
Upvotes: -1