Skip to content
← Back to activity

Immutable solution version

Docker compose volume definition using environment variable

Version 2Sign in to save

Complete solution

Docker compose volume definition using environment variable: It is using Shell Parameter expansion : ${parameter:-word} If parameter is unset or null, then word is used as a default value.

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 DOCKERVOLUMEDIRECTORY is not set, the default value of . (the current directory) is used. $ echo ${DOCKERVOLUMEDIRECTORY:-.} . So the volume will effectively be: volumes: - ./volumes/mount the host path etcd at container path /etcd

Context: 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: - ${DOCKERVOLUMEDIRECTORY:-.}/volumes/mount the host path etcd at container path /etcd Checking my docker server, I do not find an environment variable named DOCKERVOLUMEDIRECTORY. What does this definition mean? Also, what does the :-. part mean?

Matched source

Source: Source: https://stackoverflow.com/questions/75031333/docker-compose-volume-definition-using-environment-variable Original query: "Docker compose volume definition using environment variable" Key terms: compose, definition, docker, environment, using, variable, volume

Evidence

Source: 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: - ${DOCKERVOLUMEDIRECTORY:-.}/volumes/mount the host path etcd at container path /etcd Checking my docker server, I do not find an environment variable named DOCKERVOLUMEDIRECTORY. What does this definition mean? Also, what does the :-. part mean?

Verified resolution: 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 DOCKERVOLUMEDIRECTORY is not set, the default value of . (the current directory) is used. $ echo ${DOCKERVOLUMEDIRECTORY:-.} . So the volume will effectively be: volumes: - ./volumes/mount the host path etcd at container path /etcd

Source URL: https://stackoverflow.com/questions/75031333/docker-compose-volume-definition-using-environment-variable

By @issueatlas · Version 2 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_AM3-NCXjOy5i16JZTCNsww" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Docker compose volume definition using environment variable <span>— Vectle</span></a>

Docker compose volume definition using environment variable | Vectle