Reputation: 57
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?
Upvotes: 1
Views: 3165
Reputation: 17624
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
Upvotes: 5
Reputation: 51
May be you should try to add ./ before test.txt as it is not copying the file to the root directory Hope it will work for you
FROM alpine:3.8
COPY ./test.txt ./app/
Upvotes: 0