Relocating the Docker storage directory
  • 15 May 2023
  • 1 Minute to read
  • Dark
    Light
  • PDF

Relocating the Docker storage directory

  • Dark
    Light
  • PDF

Article summary

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

  1. Stop docker service.
  2. Create a folder on the new disk
  3. Move the available docker files to the new location
  4. Update the storage location
  5. Start the docker service

Procedure

  1. Open an admin cli interface
  2. Disable the docker service
cd /settings/services/
set enable_docker=no
commit
  1. 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
  1. create new folder docker in /run/media/sdb1
shell sudo su mkdir /run/media/sdb1/docker
  1. move existing files from the existing folder to the new location
shell sudo mv /var/lib/docker /run/media/sdb1/docker
  1. Restart the docker service
cd /settings/services/
set enable_docker=yes
commit
  1. From now all new and existing docker images will be started for the new location

Was this article helpful?

ESC

Eddy AI, facilitating knowledge discovery through conversational intelligence