Docker Community Forums

Share and learn in the Docker community.

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


(Maxwinther) #1

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


(Richardpayne) #2

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


(Maxwinther) #3

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