OK, this is a stupid question. Try not to laugh too hard.
In my previous experience with Docker, I used the Docker run command line. I never used Docker Compose.
From what I’ve been reading online, it says put the .yaml file in the project location. Do I need to make a directory for the container I want to run and put it there? I thought all the containers were in either /var or /usr. (been a while since I used Docker). I ran out of room on /var and /usr so some things had to go. I think Plex ran me out of space.
I wanted to run Pi-Hole in a Docker container. The .yaml file is on their github page but it doesn’t say where the file needs to be located.
A container is the isolation of processes. Where the data is has nothing to do with where your commands, scripts or yaml files are to control creating and running containers.
You can store your compose yaml file wherever you like, but yes, creating a folder for each project where you can have all files is usually a good idea, so you don’t have to pass the compose file path as a parameter just run the docker compose commands and it will recognize your compose yaml files in the folder where you run the commands.
You can try the compose getting started guide as well
Docker stores almost all container data in /var/lib/docker by default.
The storage location can be changed inside /etc/docker/daemon.json. I recommend reading docker daemon config docs. But this probably isn’t what you want to do!
Containers are by nature ephemeral. Their data isn’t persistent.
That is why we use volumes. You probably care about 2 kinds of them, named and bind volumes.
Bind volumes map host’s path to a container one.
ex.
volumes:
- './etc-pihole:/etc/pihole'
This maps host path ./etc-pihole to a container path /etc/pihole.
The . means current directory. If your compose file is in /home/mark, the volume will me stored in /home/mark/etc-pihole/.
If you want to store the volume somewhere else you can define a different path.
Let us say you want /var/mypiholevolume you would do:
volumes:
# The quotes can be there but aren't necessary for paths without spaces or special chars in names.
- /var/mypiholevolume:/etc/pihole
Named volumes can be managed through docker cli. Run docker volume --help to see more.
ex.
services:
pihole:
image: pihole/pihole:latest
# I am skipping most of the stuff
volumes:
- pihole_data:/etc/pihole
volumes:
# This is the name of the volume you can reference in this compose file.
pihole_data:
# Here you can specify additional stuff. (https://docs.docker.com/reference/compose-file/volumes/)
Those are stored inside /var/lib/docker/volumes by default.
If you want to store a specific volume on a different drive you could do some mount shennanigans.
I can walk you through it if you want. Just ask.
I am not even sure if I answered your question but I hope this brings clarification.
If you have some questions, mention me.
This is a problem. With old docker installations, the docker daemon stores it’s data in /var/lib/docker by default, with docker installations that use the containerd-snapshoter (every fresh v29+ installation, or manually configured for an old installation that was updated to v29+) stores the image and container filesystem by default in /var/lib/containerd.
No space in /var means no space to pull images, and likely no space to create containers based on images from the image cache, unless /var/lib/docker and /var/lib/containerd are on other filesystems than /var.
Storing the compose file somewhere else, and binding a different host folder to persist container data won’t change that.
Thanks!! I got the Pi-Hole container up and running.
Just one more thing, I realized docker put the container on a different subnet. I can’t access the container from my local network. Previously, when I created a container using: docker run, I specified a local (static) IP address.
A Docker bridge network is a local network on the Docker host. Even if you specify a static IP, that would not be available from outside that host. It is almost always the desired way. In other cases MacWLAN or IPVLAN is an option, but I never needed it for my use cases. You can forward the required ports using the “ports” section in the compose file.
The driver_opts you quoted can be used with port forwards, but it just makes the port forward private, so you would not be able to access it from other hosts at all.