Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Docker compose volume definition using environment variable

I’m running a containerized Milvus Standalone database (Milvus) and I’m trying to find the location of items added to the database. In the docker-compose.yml file, the volume location is defined as follows:

    volumes:
      - ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/etcd:/etcd

Checking my docker server, I do not find an environment variable named DOCKER_VOLUME_DIRECTORY.
What does this definition mean? Also, what does the

:-.

part mean?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It is using Shell Parameter expansion:

${parameter:-word}

If parameter is unset or null, then word is used as a default value.

In this case, as DOCKER_VOLUME_DIRECTORY is not set, the default value of . (the current directory) is used.

$ echo ${DOCKER_VOLUME_DIRECTORY:-.}
.

So the volume will effectively be:

volumes:
  - ./volumes/etcd:/etcd
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading