Answer the question
In order to leave comments, you need to log in
How to share a file from a container to a host in docker-compose?
Good afternoon. There is a docker-compose.yml like this:
version: '2'
services:
nginx:
image: nginx:1.13
depends_on:
- source
volumes_from:
- source
source:
image: alpine:latest
volumes:
- ./config:/etc/nginx/
open() "/etc/nginx/nginx.conf" failed (2: No such file or directory), which is logical, because we, as it were, overwrite the config folder with our own, but it is empty. How to link them correctly, provided that the ./config folder must be initially empty? Those. the type option to run without volumes -> look at the nginx config -> you do not need to offer the same in ./config.
Answer the question
In order to leave comments, you need to log in
There are 2 options to solve your problem:
1. Put all the necessary files and directories in the ./config/ directory.
2. [more correct] Mount only the
directory with configs
- ./config:/etc/nginx/conf.d
its main config will be present.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question