Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gid, uid, mount volume #397

Closed
Brandstetter opened this issue Mar 29, 2018 · 2 comments
Closed

gid, uid, mount volume #397

Brandstetter opened this issue Mar 29, 2018 · 2 comments

Comments

@Brandstetter
Copy link

RHEL 7.4 (SELinux enabled)
docker version 1.12.6
docker compose 1.15
docker compose file version 2
mysql 5.7

mysql/5.7/Dockerfile:
line 4: RUN groupadd -r mysql && useradd -r -g mysql mysql
=> user mysql uid=999 and group mysql gid=999

docker-compose file:
mysql:
image: mysql:5.7
...
volumes:
- "${DATA_DIR}/mysql_data:/var/lib/mysql:Z"
- "${BACKUP_DIR}/mysql_backup:/mysql_backup:Z"

BUT this uid and gid are already used on the host system.
DATA_DIR looks like that:
drwxr-xr-x 8 polkitd ssh_keys 4.0K 2018-03-20 13:38:30 mysql_data
And user polkitd and group ssh_keys can have different access rights as the indended mysql...

How can I start the mysql container and have uid and gid as input parameter? (of course I have to create the mysql user and group on the host system first).

@yosifkit
Copy link
Member

Just use --user on docker run (or the compose equivalent) to run as whatever user you want. They'll need to already own the folders you are mounting in since it has to skip chowning since it is not root:

$ docker run -d --user 1000:1000 -e .... mysql

@alexanderadam
Copy link

So what should be the workflow if someone wants to work with another UID/GID?

  1. regular initialization (without setting the IDs)
  2. chowning
  3. then running by setting the IDs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants