Docker Community Forums

Share and learn in the Docker community.

Is it possible to use container name for variable sostitution?

Hello,
I’m playing with docker compose and I know that docker compose support variable substitution into the values using environment variables like:

osd_xtreemfs:
image: echomany/xtreemfs:testing
volumes:
- ${VOLUME_PATH}/echomanyVolume:/var/lib/xtreemfs

And I’m wondering if I can use the container name set by docker compose during scale to set different paths like:

osd_xtreemfs:
image: echomany/xtreemfs:testing
volumes:
- ${VOLUME_PATH}/echomanyVolume/{CONTAINER_NAME}:/var/lib/xtreemfs

so that more than one instance of osd_xtreemfs will write on different directories on the host like:

/echomanyVolume/osd_xtreemfs_1/
/echomanyVolume/osd_xtreemfs_2/

/echomanyVolume/osd_xtreemfs_6/

Can I do that ?

Thanks,
Gianluca.