• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Register
  • Login
ModalAI Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
    • Register
    • Login

    execute script to start docker container on start up

    Ask your questions right here!
    2
    4
    450
    Loading More Posts
    • 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.
    • K
      kasarrowtec
      last edited by 30 Aug 2021, 09:49

      Hi,

      i am trying to execute a script that will start a docker container every time the VOXL is started.

      A lot of the suggestions for running a script on start up on linux like using crontab or systemd or rc.local is not available with this custom yocto build on the VOXL.

      Does anyone have the best way of doing this ?

      1 Reply Last reply Reply Quote 0
      • K
        kasarrowtec
        last edited by 30 Aug 2021, 09:53

        The most promising way seemed to be to make a service file in etc/systemd/system -

        [Unit]
        Description=Starts the mastervoxl docker container on startup.
        
        [Service]
        Type=simple
        ExecStart=/bin/bash /home/root/mastervoxl_init.sh
        
        [Install]
        WantedBy=multi-user.target
        

        and the script mastervoxl_init.sh being -

        #!/bin/bash
        echo 'initializing mastervoxl docker container'
        docker run -it mastervoxl /bin/bash
        
        1 Reply Last reply Reply Quote 0
        • A
          Alex Kushleyev ModalAI Team
          last edited by Alex Kushleyev 30 Aug 2021, 15:20 30 Aug 2021, 15:19

          systemd is available on VOXL, so you could go ahead and try using the service file and script you wrote. Did you try it? However, you need to make sure that the Docker service is running, so your service file should require the Docker service also running. Docker is started by systemd as well.

          1 Reply Last reply Reply Quote 0
          • K
            kasarrowtec
            last edited by 31 Aug 2021, 13:12

            So i managed to get it to work with the following service file and script file -

            [Unit]
            After=docker-autorun.service
            
            [Service]
            Type=simple
            ExecStart=/bin/bash /home/root/mastervoxl_init.sh
            
            [Install]
            WantedBy=multi-user.target
            
            #!/bin/bash
            echo 'initializing mastervoxl docker container'
            docker run --restart=always -i mastervoxl /bin/bash
            
            1 Reply Last reply Reply Quote 0
            1 out of 4
            • First post
              1/4
              Last post
            Powered by NodeBB | Contributors