Git Product home page Git Product logo

Comments (4)

alexeyp0708 avatar alexeyp0708 commented on September 17, 2024 1

@yosifkit

docker run --user 1000:1000 -e ... mysql:8.4

I'm sorry.
I didn’t immediately see the solution and didn’t understand that the mysql user is assigned only if the container is started as a root user.

from mysql.

yosifkit avatar yosifkit commented on September 17, 2024

If the mounted directories (volumes) already have the correct owner/permissions for the user that you want to run mysql as, then just run the container with that user id (and group id) and it will just work. The image is designed to run in this way.

docker run --user 1000:1000 -e ... mysql:8.4

The chown and user swap are only done when running as root (and indeed can only be done as root).

if [ "$user" = "0" ]; then
# this will cause less disk access than `chown -R`
find "${!dirs[@]}" \! -user mysql -exec chown --no-dereference mysql '{}' +

if [ "$(id -u)" = "0" ]; then
mysql_note "Switching to dedicated user 'mysql'"
exec gosu mysql "$BASH_SOURCE" "$@"

from mysql.

alexeyp0708 avatar alexeyp0708 commented on September 17, 2024

@yosifkit
volume is a universal storage to which several containers can connect, and therefore he should not depend on the settings of a specific container. Overriding the rights of a volume and its contents will disrupt the volume's interaction with other containers. If the volume and its contents are assigned to the same user and the containers communicate via the user ID(have access), the integrity of the interaction is maintained. If MYSQL supports the ability to interact with data through another user, then this possibility should be implemented in the Docker container. But you may not change anything and think that this is how it should be. At least my solution works for me.

Example: An nginx container and a php container can be configured in a way where data in a volume can be jointly managed through the user www-data(id82). Mysql container requires a special case, since they decided to hardcode 'mysql' user into the entry points. This is at least unprofessional.

from mysql.

tianon avatar tianon commented on September 17, 2024

https://hub.docker.com/_/mysql#:~:text=Running%20as%20an%20arbitrary%20user 😇

from mysql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.