• Profile photo of moonlight

      moonlight posted an update

      7 months ago

      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?

      • To avoid permissions issues, you can synchronize the user IDs (UIDs) and group IDs (GIDs) of the users in the container with the user information of the host system in the docker-compose.yml file.

        Example configuration

        version: ‘3.9’

        services:

        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.