Dockerfile file host doesn't exist

Hello,
I want to create a custom container from a dockerfile with apache2, php and sqlite3. But, when I mount the volumes for the config files apache2 or php (docker-compose), this file doesn’t appear. This config files exist in my container (when I disable the volume on docker-compose.yaml). I just want to have all files in the apache2 folder on my host to config it.

dockerfile :

FROM debian:bullseye-slim
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get -y update
RUN apt-get -y upgrade
RUN apt-get install -y jq bc curl sqlite3 libsqlite3-dev apache2 php7.4 php7.4-sqlite3
RUN /usr/bin/sqlite3 /etc/apache2/db/test.db
RUN mv /etc/cron.daily/* /home/
RUN apt-get clean autoclean
RUN apt-get autoremove --yes
RUN rm -rf /var/lib/apt/lists/*
RUN usermod -u 1008 www-data
CMD ["/usr/sbin/apache2ctl", "-DFOREGROUND"]

docker-compose

  image_apache:
    image: image_apache:latest
    container_name: image_apache
    build: /docker/image_apache
    ports:
      - "8183:80"
    volumes:
      - image_apache/www:/var/www
      - image_apache/apache2:/etc/apache2
      - image_apache/php:/etc/php
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
    restart: always

Thank for your help :wink: !

Hi, I am not sure I understand what you want to achieve here. As far as I know this is an invalid volume name: “image_apache/www”. Either you should not use “/” in the volume name to create a named volume or use relative path starting with “./” to refer to a folder on your host machine.

If you want to do the latter then I can see two options:

  1. You want to mount existing files from your host machine to the container, which should work.
  2. You want to mount an empty folder and expect the files inside the container to be copied to your local folder on your host machine. This is what will never happen. You could run a container, use “docker cp” to copy the content out to “./image_apache/www” and mount that back into the container so you could modify the files from the host.