- 15 May 2023
- 1 Minute to read
- Print
- DarkLight
- PDF
Relocating the Docker storage directory
- Updated on 15 May 2023
- 1 Minute to read
- Print
- DarkLight
- PDF
Docker containers that require a large amount of persistent data storage must be run on a dedicated 2nd disk. A dedicated disk is available on most models, or administrators can add external USB storage. In addition, administrators must change the default data storage location used by the docker service.
Overview
Note: All steps must be performed through the CLI or root shell. Configuration through the WebUI is currently not supported.
At a high level, the following steps must be performed
- Stop
docker
service. - Create a folder on the new disk
- Move the available docker files to the new location
- Update the storage location
- Start the docker service
Procedure
- Open an admin cli interface
- Disable the docker service
cd /settings/services/
set enable_docker=no
commit
- Identify the mount point of the 2nd disk
shell sudo df -hl
Example, where the 2nd disk is mounted to /run/media/sdb1 (default):
Filesystem Size Used Avail Use% Mounted on
/dev/sda4 4.7G 1.6G 3.0G 36% /
devtmpfs 7.9G 0 7.9G 0% /dev
/dev/sda3 88M 27M 55M 33% /media/hdCnf
/dev/sda8 24G 3.7G 19G 17% /media/hdVar
/dev/sda5 87M 15K 80M 1% /media/hdUser
/dev/loop0 2.0G 5.2M 1.9G 1% /media/loopfs
cgroup 7.9G 0 7.9G 0% /sys/fs/cgroup
/dev/sda7 476M 75M 402M 16% /boot
/dev/sdb1 469G 69G 376G 16% /run/media/sdb1
- create new folder docker in /run/media/sdb1
shell sudo su mkdir /run/media/sdb1/docker
- move existing files from the existing folder to the new location
shell sudo mv /var/lib/docker /run/media/sdb1/docker
- Restart the docker service
cd /settings/services/
set enable_docker=yes
commit
- From now all new and existing docker images will be started for the new location