Problem using mounting point as volume in docker container

khataev

New Member
Feb 26, 2024
3
0
1
Hi,

Sorry if this question is more docker related, but first I'll try to start here. My goal is to run mysql in docker container, while keep data outside in volume. Seem straightforward. This is a working scenario:

- LXC container (unprivileged) with docker/docker compose inside (I used tteck helper scripts).
- mysql docker container inside this LXC (I had troubles installing it in LXC, this is another topic :) )
- data volume pointing to LXC inner hard drive

Last point does not satisfy me, I do not want data to sit inside LXC container, I want it to be closer to 'outside' world. I mean proxmox storage. My choice is NAS share on adjacent Xpenology VM, so it is virtually a network share, but physically - the same NVME my proxmox is running. (Let's not pay too much attention here, it is not a production server it is a home lab on mini PC). For this setup I additionally:

- created NAS share and mounted it to Proxmox host; due to nuances of how unprivileged LXC containers work, it is done like this (uid=100000,gid=100000) - not sure if it is important here:


Code:
# /etc/fstab
//192.168.0.169/prox /mnt/hvn/prox cifs credentials=/root/.smbcredentials,uid=100000,gid=100000 0 0

added mounting point in LXC container:

Code:
mp1: /mnt/hvn/prox/volumes,mp=/mnt/hvn/prox/volumes

Here is docker compose definition:

Code:
mysql:
    container_name: mysql
    image: mysql:8.0.37-debian
    restart: always
    ports:
      - 3306:3306
    volumes:
      - /mnt/uploads:/mnt/uploads
      # inner storage (working solution)
      # - /opt/mysql/data:/var/lib/mysql
      # outer storage (non-working solution)
      - /mnt/hvn/prox/volumes/mysql/data:/var/lib/mysql

With this setup mysql container does not start. The reason is - it uses internally mysql user (999):

https://github.com/docker-library/m...83d343b186e103cd/Dockerfile.debian#L4C5-L4C51
https://github.com/docker-library/m...91e83d343b186e103cd/docker-entrypoint.sh#L376

which fails to write to this volume due to lack of permissions:

mysqld: Can't create/write to file '/var/lib/mysql/is_writable' (OS errno 13 - Permission denied)

Strange that when volume points inside LXC container it successfully takes ownership of data folder inside mounting point directory, but can't do it with NAS share. Actually I can't change ownership of this directory explicitly as well:


Code:
# on proxmox host:

root@prox:~# ls -lah /mnt/hvn/prox/volumes/mysql/data/
drwxr-xr-x 2 100000 100000 0 Jun  9 23:21 .
drwxr-xr-x 2 100000 100000 0 Jun  9 23:21 ..

root@prox:~# chown 999:999 /mnt/hvn/prox/volumes/mysql/data/

root@prox:~# ls -lah /mnt/hvn/prox/volumes/mysql/data/
drwxr-xr-x 2 100000 100000 0 Jun  9 23:21 .
drwxr-xr-x 2 100000 100000 0 Jun  9 23:21 ..

Probably this is the reason... But how to overcome this? Are there any other better ways to set up DBMS (myslq in particular) separating it from data?

Thanks in advance.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!