Home > Mobile >  Docker Named Volume on another Partition on another hard drive
Docker Named Volume on another Partition on another hard drive

Time:10-28

I have a Docker container running on my PC. The main functionality of the container is to scrape data, and this accumulates 0.3GB/day. I'll only be needing this data for the last 30 days, and after this I plan to store it archived on Hard Disk Drives for historical purposes. However after few hours of trials and errors, I've failed to create a Docker Volume on another partition, and the _data folder always appears in the /var/lib/docker/volumes/<volume_name> folder, while the partition drive is always empty.

I also tried creating the volume with docker run -v , but it still creates the volume in the main volumes folder.

The operating system is Pop!_OS 20.04 LTS

I'll provide data about the partition:

I'll provide data about the partition:

CodePudding user response:

In case of docker volumes, you don't have control over where docker saves it's volumes. all you can do is just to change docker root directory. so it's better to mount your new partition under a directory and then change docker root directory to this mount point. this way you can achieve what you want. also you should consider that by doing this, all of your docker data will be stored in this new partition.

for changing your docker root directory, you should first create a file named daemon.json in address below:

/etc/docker/daemon.json

and then add config below to it:

{
  "data-root": "/path/to/new/directory"
}

then restart docker daemon:

systemctl restart docker

then you can run command below to check current docker root directory:

docker info

CodePudding user response:

In case you are using docker volumes all your volumes data are stored in default location (/var/lib/docker) but you can change it in /etc/docker/daemon.json config file:

{
  ...

  "data-root": "/your/path/here",

  ...
}

Restart docker service to apply changes.

Docker daemon configuration file documentation here.

  • Related