Reputation: 8362
I'm using the following command to launch a Docker container.
docker run -it --rm -d -p 8080:80 \
-v ~/dev/react-using-camera/.nginx-conf-for-container/conf.d:/etc/nginx/conf.d \
-v ~/dev/nginx-test-area:/usr/share/nginx/html/ \
--name web \
nginx:stable-alpine
The command works satisfactorily:
I would like to achieve the same effect by using docker-compose up
and so I have written the following docker-compose.yml
version: "3.7"
services:
ingress:
image: nginx:stable-alpine
container_name: docker-compose-test-0
networks:
- gateway
ports:
- '8080:80'
restart: unless-stopped
volumes:
- /home/glaucon/dev/react-using-camera/.nginx-conf-for-container/conf.d:/etc/nginx/conf.d
- /home/glaucon/dev/nginx-test-area:/usr/share/nginx/html/ \
networks:
gateway: {}
When I use that file with docker-compose up
:
/home/glaucon/dev/nginx-test-area
on the host machine, instead the nginx default index.html
is served.How may I emulate the use of the '-v' arguments in my docker run
command in the context of docker-compose up
?
Upvotes: 0
Views: 109
Reputation: 20185
The second volume
-definition has a trailing backslash:
services:
ingress:
...
volumes:
...
- /home/glaucon/dev/nginx-test-area:/usr/share/nginx/html/ \
If we remove the trailing backslash:
services:
ingress:
...
volumes:
...
- /home/glaucon/dev/nginx-test-area:/usr/share/nginx/html/
it should work as expected.
Upvotes: 1