V
V
vldud2018-11-27 12:27:57
Docker
vldud, 2018-11-27 12:27:57

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/

The ./config folder is initially empty/not created. You need to link it to /etc/nginx/. The current config is throwing an error
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

1 answer(s)
I
ivankomolin, 2018-11-29
@ivankomolin

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 question

Ask a Question

731 491 924 answers to any question