Home > OS >  How to prevent docker apache from creating http folder on docker-compose up
How to prevent docker apache from creating http folder on docker-compose up

Time:10-30

I have this docker-compose file:

version: "3.2"

services:
  apache:

    build:
      context: './docker/apache/'

    ports:
      - "80"

    volumes:
      - ./:/var/www/
      
    container_name:
      apache

Dokerfile only contais this:

FROM php:7.3-apache

# i tried with this but it doesn't work
RUN rmdir /var/www/html

each time I try to up the containers it creates the html folder, how I could stop it or force it to create another named public_html?

CodePudding user response:

Try this : docker-compose.yaml

version: "3.2"

services:
  apache:

    build:
      context: './docker/apache/'

    ports:
      - "80"
      
    container_name:
      apache

Dockerfile

FROM php:7.3-apache

WORKDIR /var/www/public_html
COPY index.php .
COPY app/ /var/www

Edited after @david-maze comment.

You better to put your views wanted to be in public_html in a folder and just mount it other than all things in the current folder.As an example

volumes:
      - views/:/var/www/public_html
  • Related