I am using docker-compose.yml to run my Laravel app. Everything works fine if I run
chmod -R 755 storage
in the larval root.
But what I want is to define permission on Dockerfile. app/docker/web/Dockerfile
FROM php:7.2.10-apache-stretch
RUN apt-get update -yqq && \
apt-get install -y apt-utils zip unzip && \
apt-get install -y nano && \
apt-get install -y libzip-dev libpq-dev && \
apt-get install -y libxml2-dev && \
apt-get install -y libcurl4-openssl-dev pkg-config libssl-dev && \
a2enmod rewrite && \
docker-php-ext-configure zip --with-libzip && \
docker-php-ext-install zip && \
rm -rf /var/lib/apt/lists/*
RUN pecl install mongodb && \
docker-php-ext-enable mongodb
RUN curl -sS https://getcomposer.org/installer | php -- --install-
dir=/usr/local/bin --filename=composer
COPY default.conf /etc/apache2/sites-enabled/000-default.conf
WORKDIR /var/www/app
ADD . /var/www/app
RUN chown -R www-data: /var/www/app
RUN chmod -R 755 /var/www/app/storage
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
EXPOSE 80
And docker-compose.yml
version: '3.1'
services:
web:
container_name: ${APP_NAME}
build:
context: ./docker/web
ports:
- 8088:80
volumes:
- ./:/var/www/app
depends_on:
- mongo
links:
- mongo:mongo
mongo:
image: mongo
restart: always
ports:
- "27016:27016"
volumes:
- ./storage/mongodb:/data/db
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: password
While running docker-compose up
chmod: cannot access '/var/www/app/storage': No such file or directory
ERROR: Service 'web' failed to build: The command '/bin/sh -c chmod -R
755 /var/www/app/storage' returned a non-zero code: 1
Can anyone suggest to me what I am doing wrong? Thanks in advance.