Docker Compose - the total namespace between multiple containers

I am using docker-compose and v3. I am trying to install the volume in docker:

./appdata:/appdata

I would like to have it as a volume, and then reference this volume from several containers. the volume configuration link only shows data-volume:as a named volume with no value, so it doesn’t look like that.

services:

    nginx:
        build: ./nginx/
        ports:
            - 80:80
        links:
            - php
        volumes:
            - app-volume

    php:
        build: ./php/
        expose:
            - 9000
        volumes:
            - app-volume

volumes:
     app-volume: ./appdata:/appdata

This gives me:

ERROR: In the './docker-compose.yml' file, the volume 'app-volume' should be a mapping, not a string.

Obviously, I know that I need to change the key / value pair volumes, but I'm not sure how to change this so that I can share the volume between services.

volumes_from, . , - volumes_from , , command: true , , .

?


, :

nginx:
    volumes:
        - ./appdata:/appdata
php:
    volumes:
        - ./appdata:/appdata

, : -)

+52
2

:

services:

    nginx:
        build: ./nginx/
        ports:
            - 80:80
        links:
            - php
        volumes:
            - app-volume: location_in_the_container

    php:
        build: ./php/
        expose:
            - 9000
        volumes:
            - app-volume: location_in_the_container

volumes:
     app-volume: 

, . , web , , static-content nginx:

services:
  nginx:
    container_name: nginx
    build: ./nginx/

    volumes:
      - static-content:/usr/src/app

  web:
    container_name: web
    env_file: .env
    volumes:
      - static-content:/usr/src/app/public
    environment:
      - NODE_ENV=production

    command: npm run package

volumes:
  static-content:
+79

:

      volumes:
          - ./appdata:/appdata

, :

services:

  nginx:
      build: ./nginx/
      ports:
          - 80:80
      links:
          - php
      volumes:
          - ./appdata:/appdata

  php:
      build: ./php/
      expose:
          - 9000
      volumes:
          - ./appdata:/appdata
+19

Source: https://habr.com/ru/post/1696077/


All Articles