-
moonlight ha publicado una actualización
I’ve seen a claim that a mismatch between the permissions of a mounted local directory and the container environment may cause WordPress to not be able to write to files properly. So, how do you properly configure the permissions of the mounted volume in the Docker Compose file, or manually adjust the permissions of the local directory with commands to ensure that users inside the container can access and manipulate these files properly?
-
Para evitar problemas de permisos, puede sincronizar los ID de usuario (UID) y de grupo (GID) de los usuarios del contenedor con la información de usuario del sistema anfitrión en el archivo docker-compose.yml.
Ejemplo de configuración
versión: '3.9
servicios:
wordpress.
image: wordpress:latest
user: “1000:1000” # replace this with your local user ID and group ID
volumes.
– . /wordpress:/var/www/html
environment: .
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
wordpress WORDPRESS_DB_NAME: wordpress
image: mysql:5.7
environment: MYSQL_ROOT_PASSWORD
MYSQL_ROOT_PASSWORD: rootpassword
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
MYSQL_PASSWORD: wordpress MYSQL_PASSWORD: wordpress
– MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress
volumes: db_data:/var/lib/mysql
db_data: /var/lib/mysql
Use the id command to check your local user and group IDs:
id
For example, uid=1000 and gid=1000 in the output represent your user ID and group ID.
Replace these IDs with user: “1000:1000” to ensure that the container user and the host user are the same.
-