Set user, group, uid and gid on mysql docker container

I’m using the default mysql docker container that is published on dockerhub.

I’m using docker-compose to launch the container.

When it starts is uses uid 999 and gid 999.

I want to change the uid and gid along with the username and group to

user: mysql:2002
group: mysql:2002

I can get it to change the uid and gid by passing in the --user switch but can’t see a method of associating the correct user and group.

I’m hoping not to modify the standard mysql dockerfile as I then I have to maintain the updates.

So is there some where I can do this via docker-compose or similar?

Iű don’t understand the question.

If you can set the user id and the group id, that’s it. A user is just an ID and a config file that basically sets a label on that ID as username.

Where is this from? .

This is just show what I want to achieve.

The problem with using just IDs is that the container is creating files/directories and then setting their owner to ‘mysql’ which has an id of 999. So some of the files are not accessible.
This why I wanted to be able to control the name and uid.

I’ve raised an issue on the mysql container as this feels like a bug:

You shared a compose file in the issue using the mariadb image. That was indeed forked from MySQL, but it is not MySQL This is the mariadb image:, not what you linked in your first post.

oops, sorry. I inherited the project and assumed…