Docker Community Forums

Share and learn in the Docker community.

Docker-compose not mounting host files on service


(Croct) #1

Hi there

I have a problem with docker-compose, as the title states: host files are not appearing on image with docker compose.

I made a little example with a dockerfile and a docker-compose.yml:

docker-compose.yml

version: '2'
services:
  web:
    build: ./web
    volumes:
    - ./web/:/webapp

Dockerfile

FROM ruby:2.3.5-slim
WORKDIR $APP_HOME    ENV APP_HOME /webapp
RUN mkdir $APP_HOME
COPY . $APP_HOME/
WORKDIR $APP_HOME

Folders:

project
|- docker-compose.yml
|- /web
|----- Dockerfile
|----- MyFile

Running all commands in /project. docker-compose build finishes without errors.

Docker version 18.06.1-ce, build e68fc7a , docker-compose version 1.22.0, build unknown on a Mac mini late 2014 macOS 10.14.

Running docker-compose run web ls returns nothing. If I remove ./web/:/webapp from docker-compose.yml I get my files correctly in the image.

Why is this happening? I need to mount the /web folder to keep my files updated, but doing so it not working as expected.