Using container-name as environment parameter in docker-compose-file

Hi,

I want to mount log volume to the local file system like

 volumes:
  -/log/entities:/log

Which is straight out the box, and works perfectly. However challenges arise when using the command

docker-compose scale

Now i would have two instances or more writing to the same file. To solve this I would like something like

volumes:
- /log/{container_name}:/log

Can I do that?

regards

Max

The hostname is set to the container id so maybe just use that.

Hi,

I am using dropwizard and Java, so i changed logging file names from

currentLogFilename: log/inputoutput.log

to

currentLogFilename: log/inputoutput-${HOSTNAME}.log

I my yml files for my configuration, and that works.

regards

1 Like