Docker-compose will not use my named volumes

So, I'm pretty new to docker. I have a problem attaching my volume names to services in my swarm.

Here is my docker-compose.yml ...

version: '3'
services:
  ned:
    image: keli
    ports:
      - "8080:8080"
    depends_on:
      - craig
      - paul
  craig:
    image: cb
    volumes:
      - cbKeli:/opt/couchbase/var
    ports:
      - "8091:8091"
  paul:
    image: pg
    volumes:
      - pgKeli:/var/lib/postgresql/data
    ports:
      - "5432:5432"
volumes:
  pgKeli:
  cbKeli:

However, after a docker-compose upI get new volumes.

$ docker volume ls | grep -i keli
DRIVER              VOLUME NAME
local               cbKeli
local               kelidocker_cbKeli
local               kelidocker_pgKeli
local               pgKeli

What's up with that? How can I get a new swarm to use an existing named volume?

+4
source share
1 answer

You need to say that this is an external volume created from without. To do this, you use the foreign key in the volume definition as follows:

volumes:
  cbKeli:
    external: true
  pgKeli:
    external: true

See the following documentation for more information about external volumes: https://docs.docker.com/compose/compose-file/#external

+1

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


All Articles