I'm trying to mount a volume via docker-composer but after running docker-compose up
the directory is empty.
Dockerfile
FROM alpine:3.8
COPY test.txt ./app/
docker-compose.yml
version: "3.7"
services:
test:
image: myrep/image:latest
volumes:
- "./app/:/app/"
My procedure:
docker build .
)docker tag xxx myrep/image && docker push myrep/image
)docker pull myrep/image
)docker-compose up
)Any idea what I'm doing wrong?
You copied the file into the image, but when you start the container you overwrite it with your directory when mounting it.
If you want the file to be there don’t mount the volume.
You can verify this by running the image without a volume and executing:
docker-compose exec test ls -l /app