Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install Docker on a specific volume

Tags:

docker

Is there a way to install Docker on a specific volume ?

When I install Docker on Amazon Linux with the following command :

sudo yum install docker

and then start the docker service using :

sudo service docker start

It creates two Data Spaces :

  • Data file: /dev/loop0
  • Metadata file: /dev/loop1

How can I have those spaces be on a given volume such as /mnt/docker for example ?

like image 789
Charlesthk Avatar asked May 10 '26 00:05

Charlesthk


1 Answers

Those are device files. They will always be in /dev (actually not, but let's just assume for sake of simplicity, here). loop0 and loop1 are loop devices that are backed by the actual Docker volume files. You can easily see this using losetup -l:

> losetup -l
NAME       SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE
/dev/loop0         0      0         1  0 /var/lib/docker/devicemapper/devicemapper/data
/dev/loop1         0      0         1  0 /var/lib/docker/devicemapper/devicemapper/metadata

What you might want to do (depending on your file system layout) is moving the Docker runtime directory somewhere else (default is /var/lib/docker; all Docker volumes and images are stored there). For this, you can supply the -g flag to the Docker daemon.

In CentOS/Fedora/RHEL (and probably, because it's based on RHEL, also Amazon Linux), you can modify the /etc/sysconfig/docker file for this (look for an OPTIONS variable). In Ubuntu/Debian /etc/default/docker would be the place to look.

like image 127
helmbert Avatar answered May 12 '26 15:05

helmbert