I have this docker-compose config file:
version: '3.0'
services:
devbox:
build:
context: ./
dockerfile: DevBox.DockerFile
volumes:
- "./html:/usr/src/app"
ports:
- "80:80"
- "443:443"
devmysql:
build:
context: ./
dockerfile: MySQLDev.DockerFile
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: 'secret'
restart: always
volumes:
- "./mysql-data:/var/lib/mysql"
phpmyadmin:
image: phpmyadmin/phpmyadmin:5.0.1
restart: always
environment:
PMA_HOST: dev-mysql
PMA_USER: root
PMA_PASSWORD: secret
ports:
- "5000:80"
volumes:
mysql-data: {}
html: {}
The problem is that the volume on the devbox is empty even if the html dir is not.
If I run:
docker run -d -v ./html:/usr/src/app testdocker_devbox
It works as expected.
I don’t see problem in my config file.
My DevBox.Dockerfile is:
FROM ubuntu:latest
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y
RUN apt-get upgrade -y
RUN apt-get install -y apache2
RUN apt-get install -y php
RUN apt-get install -y php-dev
RUN apt-get install -y php-mysql
RUN apt-get install -y libapache2-mod-php
RUN apt-get install -y php-curl
RUN apt-get install -y php-json
RUN apt-get install -y php-common
RUN apt-get install -y php-mbstring
RUN apt-get install -y composer
RUN curl -s "https://packagecloud.io/install/repositories/phalcon/stable/script.deb.sh" | /bin/bash
RUN apt-get install -y software-properties-common
#RUN apt-get install -y php 7.2-phalcon
# COPY ./php.ini /etc/php/7.2/apache2/php.ini
# COPY ./slc.conf /etc/apache2/sites-available/slc.conf
# COPY ./apache2.conf /etc/apache2/apache2.conf
# RUN rm -rfv /etc/apache2/sites-enabled/*.conf
# RUN ln -s /etc/apache2/sites-available/slc.conf /etc/apache2/sites-enabled/slc.conf
CMD ["apachectl","-D","FOREGROUND"]
RUN a2enmod rewrite
EXPOSE 80
EXPOSE 443
3
Answers
I found out that the problem was with the application being on /tmp of my Mac. If I use a non /tmp path it works. This should be due to the fact that /tmp is a link to /private/tmp/
You need to remove the volumes declaration at this end of your docker-compose.yml. This is used for named volume not for volumes mapped with host directory Docker Documentation.
Change local path
./html
into absolute path