Docker container take 20 minutes to start

  • Platform information:
    • Hardware: Xeon Gold W-2275
    • OS: Unraid 6.9.2 - Openhab Official Docker latest-debian
    • Java Runtime Environment: Whatever is included in the docker image
    • openHAB version: 3.1.0

When starting the docker container, it is stuck at the “sync” command for 15-20 minutes. If I run
watch -d grep -e Dirty: -e Writeback: /proc/meminfo
in the container, I can see that dirty amount is over 16GB
Dirty: 15216784 kB
Writeback: 273708 kB

My server consist of 128GB ram and 3x 16TB (1 is for parity in unraid).
Here is the docker logs file

+ IFS='
        '
+ '[' unlimited = unlimited ']'
+ echo 'Configuring Zulu JDK 11 unlimited strength cryptography policy...'
Configuring Zulu JDK 11 unlimited strength cryptography policy...
+ sed -i 's/^crypto.policy=limited/crypto.policy=unlimited/' /usr/lib/jvm/default-jvm/conf/security/java.security
+ rm -f /openhab/runtime/instances/instance.properties
+ rm -f /openhab/userdata/tmp/instances/instance.properties
+ NEW_USER_ID=9001
+ NEW_GROUP_ID=9001
+ echo 'Starting with openhab user id: 9001 and group id: 9001'
Starting with openhab user id: 9001 and group id: 9001
+ id -u openhab
++ getent group 9001
+ '[' -z '' ']'
+ echo 'Create group openhab with id 9001'
Create group openhab with id 9001
+ groupadd -g 9001 openhab
+ echo 'Create user openhab with id 9001'
Create user openhab with id 9001
+ adduser -u 9001 --disabled-password --gecos '' --home /openhab --gid 9001 openhab
Warning: The home dir /openhab you specified already exists.
Adding user `openhab' ...
Adding new user `openhab' (9001) with group `openhab' ...
The home directory `/openhab' already exists.  Not copying from `/etc/skel'.
adduser: Warning: The home directory `/openhab' does not belong to the user you are currently creating.
+ groupadd -g 14 uucp2
+ groupadd -g 16 dialout2
+ groupadd -g 18 dialout3
+ groupadd -g 32 uucp3
+ groupadd -g 997 gpio
+ adduser openhab dialout
Adding user `openhab' to group `dialout' ...
Adding user openhab to group dialout
Done.
+ adduser openhab uucp
Adding user `openhab' to group `uucp' ...
Adding user openhab to group uucp
Done.
+ adduser openhab uucp2
Adding user `openhab' to group `uucp2' ...
Adding user openhab to group uucp2
Done.
+ adduser openhab dialout2
Adding user `openhab' to group `dialout2' ...
Adding user openhab to group dialout2
Done.
+ adduser openhab dialout3
Adding user `openhab' to group `dialout3' ...
Adding user openhab to group dialout3
Done.
+ adduser openhab uucp3
Adding user `openhab' to group `uucp3' ...
Adding user openhab to group uucp3
Done.
+ adduser openhab gpio
Adding user `openhab' to group `gpio' ...
Adding user openhab to group gpio
Done.
+ initialize_volume /openhab/conf /openhab/dist/conf
+ volume=/openhab/conf
+ source=/openhab/dist/conf
++ ls -A /openhab/conf
+ '[' -z 'html
icons
items
persistence
rules
scripts
services
sitemaps
sounds
things
transform' ']'
+ initialize_volume /openhab/userdata /openhab/dist/userdata
+ volume=/openhab/userdata
+ source=/openhab/dist/userdata
++ ls -A /openhab/userdata
+ '[' -z 'backup
cache
config
etc
jsondb
kar
logs
secrets
tmp' ']'
++ cmp /openhab/userdata/etc/version.properties /openhab/dist/userdata/etc/version.properties
+ '[' '!' -z ']'
+ chown -R openhab:openhab /openhab
+ sync

It is a brand new openhab installation. I didn’t even tried to restore my backup from my other server yet. I tried with all network mode possible, but it has nothing to do with network since once this is done, the server run perfectly. But since that step is ran twice, at every boot (why?), it’s very long to start/restart the server

ok, it seems the problem was because I was copying a very large amount of data at the sametime, even if it wasn’t remotly close to be on the same drive, the sync was invoked for all drive thus making everything very slow. Once the data copy was done, openhab start in a split seconds.

But why is there sync command in the container to begin with?

It seems to prevent another issue:

could just put a wait 5 sec… When running on a NAS with a cache system, it make startup a pain if there’s file transfer. Maybe make an option we could pass as a command to put run a wait instead of a sync?

think we could put a env var to skip the sync? I have this problem again today. Ran a restart and I’ve been waiting for the last 45 minute on the first sync… Running in a docker on unraid, sync is really not needed