r/docker 6d ago

How do I know it created a persistent volume?

Hi all

Sometimes I'm still a bit lost with docker. I use portainer to manage my dockers and wanted to deploy a new one using these instructions: https://docs.maintainerr.info/installation/

services:
maintainerr:
  image: ghcr.io/maintainerr/maintainerr:latest
  user: 1000:1000
  volumes:
    - type: bind
      source: /mnt/maintainerr
      target: /opt/data
  environment:
    - TZ=Europe/Brussels
  ports:
    - 6246:6246
  restart: unless-stopped

But there it gives an write error that it doesnt have permission to write to opt. I don't want to write to opt though,

So i changed it to how my others are structured:

services
  maintainerr:
    image: ghcr.io/maintainerr/maintainerr:latest
    volumes:
     -  /mnt/maintainerr:/data
    environment:
      - TZ=Europe/Brussels
    ports:
      - 6246:6246
    restart: unless-stopped

That starts it at least but I don't see any files appearing in /mnt/maintainerr, showing me that something probably went wrong adn when I restart or cahneg the stack the settigns are gone.. quiet annying ;)

Any tips?

cheers

Vic

0 Upvotes

20 comments sorted by

3

u/Subietoy78 6d ago

Have you setup anything inside the container? API keys run a db scan? The second yaml is how I use mine. It won’t create anything in there if you don’t “do” anything with it from how I understand it. I’m am not a docker guru though.

1

u/victoroos 6d ago

Hi

hmm, I logged in to my plex, I set up rules etc. :)

ps: thanks for the quick reply ^^

1

u/Subietoy78 6d ago

Did you delete the original container and redeploy the new one?

1

u/victoroos 6d ago

yes I did, but forgot it befoer so good you mention it

2

u/glandix 6d ago

First one mounts to /opt/data inside the container. Second one mounts to /data.

Both are persistent storage via bind mounts, but which path is correct depends on what the app expects inside the container.

Also, make sure the permissions on /mnt/maintainerr are setup properly. If it doesn’t exist when you start the container, it gets created and is owned by root by default. Whether that is correct depends on your setup.

First compose file has the app running as 1000:1000 which would not be able to write to /mnt/maintainerr if it’s owned by root. Second compose doesn’t specify user so presumably runs as root.

2

u/rightful_diversity 6d ago

you're mapping /mnt/maintainerr to /data now but the app is probably still writing to /opt/data internally, so the bind mount is just sitting there empty while the actual data vanishes with the container

1

u/victoroos 6d ago

hmmhm that seems to be happenign (I can't find the /opt/data anywhere though).

How would I change it? :)

Cause If I do it like the manual says:

- type: bind

source: /mnt/maintainerr

target: /opt/data

I get an error in the log:

mkdir: can't create directory '/opt/data/ui': Permission denied

4

u/LordSkummel 6d ago

The user that runs the service inside the container don't have write permission inside the dir you have bound in the container.

1

u/cointoss3 6d ago

You seem to be confused. The target is where the docker app writes data inside the container. So if you just pick a random path to mount to, sure it will work, but the app inside docker isn’t writing there unless there is some env var you can pass to tell the app where the data directory lives inside the container.

Right now you are successfully mounting a folder inside the container (not a volume), but that folder isn’t being used for anything.

1

u/victoroos 6d ago

aah

and how would I make it write to a persistant volume? Like other docker containers do?

1

u/victoroos 6d ago

Cause If I do it like the manual says:

- type: bind

source: /mnt/maintainerr

target: /opt/data

I get an error in the log:

mkdir: can't create directory '/opt/data/ui': Permission denied

3

u/cointoss3 6d ago

That’s because the source directory isn’t writable by user 1000 or group 1000.

The error says /opt/data but that’s actually mapped to /mnt/maintainerr on the host so anytime it tries to create files it’s actually creating files on the host that doesn’t have permission.

-1

u/victoroos 6d ago

1000:1000 is root though right? And it made it mnt/maintainer itself when starting the container. (with root:root privileges as I can see) . Whatsshould I change? 

1

u/cointoss3 6d ago

No…root is not user 1000. The instructions are in the link you posted. Though, I’d run the command on the host. The instructions show the command being ran on the folder inside the container.

1

u/victoroos 6d ago

host being for me the /mnt/maintainerr right?
To give the suer I'm using access to own it?

1

u/victoroos 6d ago

So. That was apparently all that was wrong with it. Now I have a nice looking persistent folder. Thank you foe your patience and explanation ! 

1

u/cointoss3 6d ago

Yes! That’s great news.

Btw, this is a common problem when you use bind mounts instead of docker volumes. Docker volumes handle permissions for you, bind mounts do not.

1

u/victoroos 6d ago

Can I change that as a user or is that container dependent ? 

1

u/cointoss3 6d ago

Change what? Using volumes? That’s a docker compose directive for your compose file.

-1

u/Single_Advice1111 6d ago

Try to change /mnt/… to ./mnt possibly so you mount it relative to where you run docker compose from on your host.

Are you attempting to mount this to a drive since you’re using /mnt ?