Docker compose and /etc/localtime

bedaro

Cadet
Joined
Apr 23, 2022
Messages
8
I'm trying to get docker-mailserver https://github.com/docker-mailserver/docker-mailserver running with docker compose. One key line in the docker-compose.yml file seems to cause deployment with portainer to fail:

Code:
volumes:
  - /etc/localtime:/etc/localtime:ro


If I remove this then the container launches successfully, but with it present I just get a cryptic "400 bad request" message. Do I have to bind /etc/localtime to the TrueNAS host somehow to get this to work? Perhaps in "Storage and Persistence" on the docker-compose configuration?
 

morganL

Captain Morgan
Administrator
Moderator
iXsystems
Joined
Mar 10, 2018
Messages
2,694
Are you doing this with TrueCharts docker-compose App?
 

bedaro

Cadet
Joined
Apr 23, 2022
Messages
8
Yes, with TrueCharts docker-compose.

It looks like the problem may be that /etc/localtime does not exist inside the container. Attempting to bind mount it causes it to get autocreated as a directory, which then fails because you can't mount a file to a directory.
 

bedaro

Cadet
Joined
Apr 23, 2022
Messages
8
If I install a TrueCharts docker-compose app using a working docker-compose.yml (only containing portainer), I can then get it to start and open a shell inside the container. Adding my YAML config for docker-mailserver when it contains that above binding for /etc/localtime produces this error when I try to bring it up:

Code:
Starting mailserver ... error

ERROR: for mailserver  Cannot start service mailserver: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:75: mounting "/etc/localtime" to rootfs at "/etc/localtime" caused: mount through procfd: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

At first /etc/localtime does not exist at all, but after attempting to start the new service there is a directory called localtime in /etc. But if I manually create an empty localtime file in /etc before starting the service then it works fine.
 

morganL

Captain Morgan
Administrator
Moderator
iXsystems
Joined
Mar 10, 2018
Messages
2,694
If I install a TrueCharts docker-compose app using a working docker-compose.yml (only containing portainer), I can then get it to start and open a shell inside the container. Adding my YAML config for docker-mailserver when it contains that above binding for /etc/localtime produces this error when I try to bring it up:

Code:
Starting mailserver ... error

ERROR: for mailserver  Cannot start service mailserver: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:75: mounting "/etc/localtime" to rootfs at "/etc/localtime" caused: mount through procfd: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

At first /etc/localtime does not exist at all, but after attempting to start the new service there is a directory called localtime in /etc. But if I manually create an empty localtime file in /etc before starting the service then it works fine.
You can let the TrueCharts team know via their discord channel. It sounds like they could fix it in the Docker-Compose App.
 

bedaro

Cadet
Joined
Apr 23, 2022
Messages
8

truecharts

Guru
Joined
Aug 19, 2021
Messages
788
I found a submitted issue on TrueCharts for this, so they already know about it. https://github.com/truecharts/apps/issues/2419
It's not going to help you asking here, instead of asking us directly.
Simply put: The people building this are not here to help you out, nor is (most of) our support staff. So if there is a work-around, this is not likely to be the place you'll get info about it ;-)
 

bedaro

Cadet
Joined
Apr 23, 2022
Messages
8
Oh I think you misunderstood, finding that it's a known issue is enough for me to move on and find some other way (such as setting TZ environment variable)
 
Top