Container has no network

Discussion about Docker
User avatar
mukmuk
Posts: 25
Joined: 08 Jan 2021, 21:39

Re: Container has no network

Post by mukmuk »

I didn't automate the route changes after reboot yet, because the NAS is running pretty stable and the uptime is at about 40 days, so yeah. But instead of a cron job, I created a script in /etc/init.d/. The file name should be something like S99zzzmyscript, so that it will load at a later time (when nasips has already been started).

Code: Select all

$ touch /etc/init.d/S99zzzmyscript
$ touch /etc/sc.d/S99zzzmyscript
$ chmod u+rwx /etc/init.d/S99zzzmyscript
$ vi /etc/init.d/S99zzzmyscript
Content of /etc/init.d/S99zzzmyscript:

Code: Select all

#!/bin/bash

/usr/bin/logger S99zzzmyscript executed

## rewrite config
/bin/sed -i 's/jumpd = YES/jumpd = NO/g' /etc/nasips.ini

## restart service
/sbin/service S99nasips restart

## is traefik running?
CONTAINERRUNS=`docker inspect -f {{.State.Running}} traefik`
STATUSTRUE=true

if [ "$CONTAINERRUNS" = "$STATUSTRUE" ]; then
    /usr/bin/logger traefik runs fine
else
    /usr/bin/logger traefik restarted
    /mnt/md0/application/bin/docker restart traefik
fi

exit 0
The script and comments are pretty straight forward. One last thing that would be missing is the change of the routes + ips. But it shouldn't be a problem from there on. The empty file /etc/sc.d/S99zzzmyscript makes sure, that our init.d script gets executed on every boot.
Locked