Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (12.7k points)

version: '2'

services:

    web:

        build:

            context: ./

            dockerfile: deploy/web.docker

        volumes:

            - ./:/var/www

        ports:

            - "8080:80"

        links:

            - app

How can I change permission (chmod) /var/www automatically when docker-compose up -d --build?

1 Answer

0 votes
by (29.5k points)

When bind-mounting a directory from the host in a container, files and directories maintain the permissions they have on the host. This is by design: when using a bind-mount, you're giving the container access to existing files from the host, and Docker won't make modifications to those files; doing so would be very dangerous (for example, bind-mounting your home-directory would change file permissions of your host's home directory, possibly leading to your machine no longer being usable).

To change permissions of those files, change their permissions on the host.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...