execute script to start docker container on start up
-
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 ?
-
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.targetand the script mastervoxl_init.sh being -
#!/bin/bash echo 'initializing mastervoxl docker container' docker run -it mastervoxl /bin/bash -
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.
-
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
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