0

I have docker-compose file, where I have specified volumes:

    services:

        portal:
            env_file:
            - ${ENV_FILE}
            build:
            context: .
            dockerfile: ./Dockerfile
            container_name: sensus-portal
            image: sensus-portal
            hostname: ${DOMAIN}
            working_dir: /var/www/html
            volumes:
            - ../localhost-certificates:/var/certificates
            - ./portal:/var/www/html
            - ../wp-content:/var/www/html/wp-content
            ports:
            - "80:80"
            - "443:443"

Problem is that when last volume added, it replaces previous stuffs which was in var/www/html/wp-content ... I want to assign volume /var/www/html and then into this add (merge) volume /var/www/html/wp-content.

Is there any chance how to do this?

Rmahajan
  • 1,311
  • 1
  • 14
  • 23
Kristián Stroka
  • 698
  • 1
  • 8
  • 23
  • 1
    Possible duplicate of [Can we mount sub-directories of a named volume in docker?](https://stackoverflow.com/questions/38164939/can-we-mount-sub-directories-of-a-named-volume-in-docker) – John Feb 05 '19 at 13:00

1 Answers1

0

No, there’s no way to merge the contents of two volumes or host directories. This works the same way as normal Linux mount(8): the directory or volume you’re mounting into the container hides whatever was there already, and there’s no way to get at the hidden content.

The Dockerfile COPY directive is a little more flexible this way and you might consider building this content into your image.

David Maze
  • 130,717
  • 29
  • 175
  • 215