Reputation: 7679
This command sudo docker build -t mydocker .
build the image in /var/lib/docker
. Is there a way to change it to another folder e.g. /home/user1/docker
?
Upvotes: 4
Views: 4970
Reputation: 761
For the new version of Docker, you have to change daemon.json.
sudo nano /etc/docker/daemon.json
then add the path to the deamon JSON (In my case path is '/media/newhd/containers/')
{"data-root":"/media/newhd/containers/"}
After this restart the docker...
Upvotes: 3
Reputation: 61521
You have to restart the docker daemon with the -g
option.
docker -d -g /home/user1/docker
or
docker -d --graph="/home/user1/docker"
Keep in mind that once you do this, all your images for that docker daemon instance will get stored on /home/user1/docker
And also that generally the Docker daemon runs a root
. So it's probably better to specify a directory owned by root
Upvotes: 2