How to use bash commands alongside Docker restart policies? [closed]

asked 2021-02-17 08:26:56 -0500

Py gravatar image

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?

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant. Please see http://wiki.ros.org/Support for more details. by gvdhoorn
close date 2021-02-17 08:38:11.960433

Comments

1

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.

gvdhoorn gravatar image gvdhoorn  ( 2021-02-17 08:38:02 -0500 )edit
1

Thanks for the advice. Much appreciated, I've posted this here.

Py gravatar image Py  ( 2021-02-17 08:42:00 -0500 )edit