How to use bash commands alongside Docker restart policies? [closed]
In a ROS project, I have the following bash script that I use to run a docker container:
#!/bin/bash
source ~/catkin_ws/devel/setup.bash
rosnode kill some_ros_node
roslaunch supporting_ros_package launch_file.launch &
docker run -it \
--restart=always \
--privileged \
--net=host \
my_image:latest \
/bin/bash -c\
"
roslaunch my_package my_launch_file.launch
"
export containerId=$(docker ps -l -q)
However, what I'd like to happen is, for every time the container restarts (especially as the machine is booted up), the bash commands preceding the docker run
command to also re-run on the host machine (not within the container).
How might I achieve this?
Unfortunately this appears to not really be a ROS question. You're using ROS, that's clear, but the question is really about Docker,
--restart=always
and shell scripting.Please post your question on a more appropriate forum.
If/when you do post somewhere else, please post a comment here with a link to your new post, so we can keep things connected.
Thanks for the advice. Much appreciated, I've posted this here.