Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Docker "Extra Parameters" only seem to run on creation of container, not starting of container

Featured Replies

I have a docker container that connects to my personal weather station (PWS) that is connected through USB. This device will randomly disconnect and reconnect (it's a "feature" of the panel), so I created some rules to give the device a name. This name is static, and will update when it reconnects. Let's say the device is /dev/mypws.

 

In Extra Parameters, I have this "--device=$(readlink -f /dev/mypws)"

This works great! When I create the container, everything works flawlessly.

 

However, when I restart the container, it doesn't run again, so the container still has the old endpoint. I would love for this command to run every time it starts. How do I get it to do that?

 

I have tried passing /dev/mypws as a device to the docker container, but it doesn't seem to like that very much for some reason.

 

If anyone has any ideas on how to pass the device in a way I haven't thought of, or some way to run the command every time I start the container, that would be fantastic.

  • Author

I was able to make a workaround using user scripts, but it's definitely not my favorite.

 

#!/bin/bash
trap exit SIGQUIT SIGINT
echo $(date -u) "Starting Script"
devloc=$(readlink -e /dev/mypws)
echo $(date -u) "PWS is at: $devloc"
echo $(date -u) "Starting device watchdog..."
while :; do
    newloc=$(readlink -e /dev/mypws)
    if [[ "$devloc" != "$newloc" ]];then
        if [[ "$newloc" != "" ]];then
            echo $(date -u) "Device detected at a different node, running script"
        fi
        
        if [ -e /dev/mypws ]
        then
            echo $(date -u) "PWS Connected, setting permissions"
            sudo chown nobody:users /dev/bus/usb/003/* 
            sudo chmod 777 /dev/bus/usb/003/* 
            echo $(date -u) "Stopping Weewx"
            docker stop Weewx >> /dev/null
            echo $(date -u) "Removing Weewx"
            docker rm Weewx >> /dev/null
            echo $(date -u) "Restarting Weewx"
            docker run -d --name='Weewx' --net='bridge' --cpuset-cpus='2,8' -e TZ="America/Chicago" -e HOST_OS="Unraid" -e HOST_HOSTNAME="tower" -e HOST_CONTAINERNAME="Weewx" -e 'TIMEZONE'='America/Chicago' -e 'WEEWX_UID'='99' -e 'WEEWX_GID'='100' -l net.unraid.docker.managed=dockerman -l net.unraid.docker.icon='https://www.weewx.com/images/weewx-logo-128x128.png' -v '/mnt/user/appdata/weewx':'/data':'rw' --device=$(readlink -e /dev/mypws) 'felddy/weewx' >> /dev/null
            echo $(date -u) "Weewx Restarted"
            devloc=$newloc
            echo $(date -u) "PWS is now at: $devloc"
            echo $(date -u) "Resuming folder monitoring..."
        else
            echo $(date -u) "Device not connected"
            devloc="";
        fi
    fi
    sleep 10
done

 

Edited by Aathroser
consistency

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.