Change location of containers (Linux)

I’m vary much the n00b, so this may be a terminology problem.

This will be on a fresh install (openSUSE-Leap-15.6-Build710.3-KDE)
I see that I need to edit daemon.json and different people say different things on what is needed. What I see on most is change data-root.

I want to keep the program Docker in / (SDC1) but put the containers on a different drive (SDB1).

How do I change the location of container, but not the program?

P.S. I guess I should ask also, this is to run a forum (Simple Machines Forum). Will docker keep ALL the data (pictures & text) in the container? The forum may want to store it somewhere else.

1 Like

The data-root specifies the directory for the persistent docker engine data, like container configuration, volume configurations, network configuration, image layers and the metadata that makes them an image, container filesystems.

This directory does not store any binaries of the docker engine.

If it’s about persisting the data of containers:

A container is ephemeral/disposable by design: its state is tied to its lifecycle, if a container is deleted, its state is deleted as well.

To persist permanent data, volumes are used to either mount host paths or docker named volumes into container paths, so that the data is actually stored outside the container → Not tied to the containers lifecycle anymore.

Make sure to read the image description to understand which container paths the image maintainer expects to be mounted as volume (and as such stored outside the container itself).

1 Like

Stop Docker, edit /etc/docker/daemon.json to set "data-root": "/mnt/sdb1/docker" , restart Docker. For forum data, use volumes (e.g., -v /mnt/sdb1/forum-data:/container/path ) to store files outside containers. Docker won’t persist data without volumes. Keep program files in default location, containers/data on SDB1.