Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
Collapse
Brand Logo

ModalAI Forum

  1. ModalAI Support Forum
  2. Ask your questions right here!
  3. Autostart docker containers via docker-autorun.service not working

Autostart docker containers via docker-autorun.service not working

Scheduled Pinned Locked Moved Ask your questions right here!
12 Posts 3 Posters 2.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • kasarrowtecK Offline
    kasarrowtecK Offline
    kasarrowtec
    Contributor
    wrote on last edited by
    #1

    Hi,

    We are using a VOXL flight deck with LTE and require that the drone starts some c++ logic inside a container on start up. We have done this through the docker-autorun.service file below -

    [Unit]
    After=docker-daemon.service
    Requires=docker-daemon.service
    
    [Service]
    
    Type=forking
    
    ExecStartPre=/usr/bin/docker-prepare.sh
    ExecStart=/etc/modalai/docker-autorun-script.sh
    #ExecStop=/bin/bash -c "docker kill $(docker ps -q)"
    
    [Install]
    WantedBy=default.target
    

    Then inside the docker-autorun-script.sh we have the following -

    echo "initializing primevoxl"
    
    ((count =60))
    while [[ $count -ne 0 ]] ; do
        ping -c 1 8.8.8.8                    # Try once.
        rc=$?
        if [[ $rc -eq 0 ]] ; then
            ((count = 1))                    # If okay, flag loop exit.
        else
            sleep 1                          # Minimise network storm.
        fi
        ((count = count - 1))                # So we don't go forever.
    done
    
    if [[ $rc -eq 0 ]] ; then               # Make final determination.
    docker run -i --restart=always --privileged --net=host primevoxl &
    else
        echo "Timeout"
    fi
    

    The code does a ping test then on success runs a docker container via -
    docker run -i --restart=always --privileged --net=host primevoxl &

    The docker image ends with starting a piece of c++ code via a CMD in the dockerfile. The code that we run inside the container is a simple pubsub code with AWS IoT core to listen for missions etc. this works fine with no errors when i run the container normally and even when i run /etc/modalai/docker-autorun-script.sh it works fine and gets a connection.

    But when the docker-autorun-script.sh is started with the service file on reboot we get the following error -
    error-code.jpg

    I cant seem to see where the error lies and whether i am starting the container correctly via service ?

    1 Reply Last reply
    0
    • kasarrowtecK Offline
      kasarrowtecK Offline
      kasarrowtec
      Contributor
      wrote on last edited by
      #2

      also the SD card has been emptied and has more then enough available space - regardless of the error code.

      Eric KatzfeyE 1 Reply Last reply
      0
      • kasarrowtecK kasarrowtec

        also the SD card has been emptied and has more then enough available space - regardless of the error code.

        Eric KatzfeyE Offline
        Eric KatzfeyE Offline
        Eric Katzfey
        ModalAI Team
        wrote on last edited by
        #3

        @kasarrowtec How are you connecting to the Internet?

        1 Reply Last reply
        0
        • kasarrowtecK Offline
          kasarrowtecK Offline
          kasarrowtec
          Contributor
          wrote on last edited by
          #4

          via the LTE module for the VOXL, using a sim cardphoto_2022-03-29_10-16-44.jpg

          1 Reply Last reply
          0
          • kasarrowtecK Offline
            kasarrowtecK Offline
            kasarrowtec
            Contributor
            wrote on last edited by
            #5

            I believe it may be an issue with the wifi connecting alongside the LTE and breaking the docker container when a new host is added to ifconfig.

            1 Reply Last reply
            0
            • kasarrowtecK Offline
              kasarrowtecK Offline
              kasarrowtec
              Contributor
              wrote on last edited by
              #6

              i tried disabling the wifi service so the VOXL only uses LTE and it still gives the same error.

              I disabled the wifi through systemctl disable wlan-daemon.service

              1 Reply Last reply
              0
              • kasarrowtecK Offline
                kasarrowtecK Offline
                kasarrowtec
                Contributor
                wrote on last edited by
                #7

                when i do not use the --net=host flag it does work !

                but to pass through the ports we need i added the -p 14551:14551 flag but was met with this error from docker -

                failed to create endpoint on network bridge: iptables failed: iptables -t nat -A DOCKER -p tcp -d 0/0 --dport 14551 -j DNAT --to-destination 172.17.0.2:14551 ! -i docker0: iptables: No chain/target/match by that name.
                

                any idea how i might fix this ?

                1 Reply Last reply
                0
                • kasarrowtecK Offline
                  kasarrowtecK Offline
                  kasarrowtec
                  Contributor
                  wrote on last edited by
                  #8

                  I understand the docker kernel is a little different on the VOXL so if you could just tell me how you would map ports from the VOXL to the container ? as -p is not working

                  ive also tried --add-host and --expose

                  Eric KatzfeyE 1 Reply Last reply
                  0
                  • kasarrowtecK kasarrowtec

                    I understand the docker kernel is a little different on the VOXL so if you could just tell me how you would map ports from the VOXL to the container ? as -p is not working

                    ive also tried --add-host and --expose

                    Eric KatzfeyE Offline
                    Eric KatzfeyE Offline
                    Eric Katzfey
                    ModalAI Team
                    wrote on last edited by
                    #9

                    @kasarrowtec It's difficult to follow exactly what you are trying to do. In general, you should debug everything before trying to make it start using a systemd service file. It sounds like you have done that, but once you start it as a service it no longer works. That usually means that it is dependent on some other system services that have not yet started when systemd starts your service. The key is to identify what those services are and add proper dependencies into your service file for them. You could also add a pause or sleep into your service file before starting your application. This gives time for the other dependencies to start before your application starts.

                    1 Reply Last reply
                    0
                    • kasarrowtecK Offline
                      kasarrowtecK Offline
                      kasarrowtec
                      Contributor
                      wrote on last edited by
                      #10

                      Thanks for the suggestion Eric but unfortunately i have tried those suggestions. I have identified the last executing service file on boot and made the docker-autorun.service run after and also added a sleep and a ping test.

                      I have come to the conclusion that --net=host is causing the problem, im not sure why. So i need to pass the ports through when running the container via a different method.

                      Do you guys have a certain way of passing ports through when running docker containers on the VOXL ? something like docker run -p 14551:14551 ?

                      Eric KatzfeyE David SmitsD 2 Replies Last reply
                      0
                      • kasarrowtecK kasarrowtec

                        Thanks for the suggestion Eric but unfortunately i have tried those suggestions. I have identified the last executing service file on boot and made the docker-autorun.service run after and also added a sleep and a ping test.

                        I have come to the conclusion that --net=host is causing the problem, im not sure why. So i need to pass the ports through when running the container via a different method.

                        Do you guys have a certain way of passing ports through when running docker containers on the VOXL ? something like docker run -p 14551:14551 ?

                        Eric KatzfeyE Offline
                        Eric KatzfeyE Offline
                        Eric Katzfey
                        ModalAI Team
                        wrote on last edited by
                        #11

                        @kasarrowtec I'm not sure that anyone has ever had the need to pass ports like that.

                        1 Reply Last reply
                        0
                        • kasarrowtecK kasarrowtec

                          Thanks for the suggestion Eric but unfortunately i have tried those suggestions. I have identified the last executing service file on boot and made the docker-autorun.service run after and also added a sleep and a ping test.

                          I have come to the conclusion that --net=host is causing the problem, im not sure why. So i need to pass the ports through when running the container via a different method.

                          Do you guys have a certain way of passing ports through when running docker containers on the VOXL ? something like docker run -p 14551:14551 ?

                          David SmitsD Offline
                          David SmitsD Offline
                          David Smits
                          wrote on last edited by
                          #12

                          @kasarrowtec Did you get any further with this issue. I have the same problem that Docker can not create an endpoint in the iptables.

                          1 Reply Last reply
                          0

                          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                          With your input, this post could be even better 💗

                          Register Login
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          ModalAI
                          Categories Recent Tags ModalAI.com Docs
                          © 2026 ModalAI® · Accelerating autonomy for smaller, smarter, safer drones · Powered by NodeBB
                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups