I have a project with the following structure:
- my-project/
- docker-compose.yml
- web
- Dockerfile
- src/
I am trying to setup docker-compose.yml, so that the web
service will start up in a docker container, and web/
directory will be mounted under /app
in the docker container. This will enable me to edit the source files on the host system, and they will be recompiled in the docker container (let’s say this is a Rails app).
Currently my docker-compose.yml
looks like this:
version: "2"
services:
web:
build: web
image: web
volumes:
- ./web:/app
This docker-compose.yml
does use web/Dockerfile
to build the web image, and it starts it up, but /app
directory in the running container is always empty. I cannot figure out why that’s the case. I can get what I want by using docker directly (by running the following in the web/
directory: docker run -v $(pwd)/web:/app -it --rm web /bin/bash
), but this is not going to work with multiple web-like services (hence why I’m trying to use docker-compose
).
Can anyone see what is wrong here?
Some resources:
- https://github.com/zoran119/haskell-webservice (sample project demonstrating my problem)
- https://stackoverflow.com/questions/46131081/setting-up-docker-compose-for-development (my question about this on SO)