Ask Your Question

Docker-Compose won't launch ros node, but Docker run will

asked 2021-07-13 09:17:06 -0600

XDGFX gravatar image

I'm having a strange issue running a ROS Melodic node inside a Docker container.

Within the container I want to launch row_follower.launch inside the navvy_row package. If I run the container with a command argument, docker run --rm -it --net host navvy_row roslaunch navvy_row row_follower.launch, the node starts without issue:

... logging to /root/.ros/log/a5064c4a-e3e2-11eb-b627-48b02d0788d9/roslaunch-nanoboi-235.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://nanoboi:45713/


 * /ransac_row_followerv2/LeftRightThreshold: 0.8
 * /ransac_row_followerv2/PPMultiplier: 5

However if I try the same using docker-compose and the below entry:

    container_name: navvy_row
    image: navvy_row
    build: navvy_row/
    network_mode: host
    command: roslaunch navvy_row row_follower.launch

I get no output past the echo from / I know the workspace is sourced correctly because replacing the command: with rospack find navvy_row returns the location as expected.

Attaching to the container and launching the launchfile starts as expected, but then the original docker-compose logs show an error because two nodes were registered with the same name, starts loading the new node and then the whole container exits.

navvy_row    | [ WARN] [1626185169.544579230]: Shutdown request received.
navvy_row    | [ WARN] [1626185169.544793054]: Reason given for shutdown: [[/ransac_row_followerv2] Reason: new node registered with same name]
navvy_row    | [ INFO] [1626185126.115699876]: Starting ransac row node
navvy_row    | [ INFO] [1626185126.259093209]: Finished Setup, Starting Spinning

If I don't start roscore on the host before trying to launch the container, if it's the only container the same thing happens (nothing).

If I have another ros1 container running it seems to sometimes get further but always results in an error from one of the containers:

RLException: run_id on parameter server does not match declared run_id: 13e8b156-e3e4-11eb-b345-48b02d0788d9 vs 13e26936-e3e4-11eb-8394-48b02d0788d9

I've run out of ideas on how to fix this, any help much appreciated!

edit retag flag offensive close merge delete


I'm afraid there are things you haven't described about your environment. First sharing the content of .launch file helps.

If I don't start roscore on the host before trying to launch the container,

What is this? Is running roscore aside from the docker-compose process in question a requirement?

130s gravatar image 130s  ( 2021-07-13 12:03:10 -0600 )edit

This is the contents of the .launch file:

<?xml version="1.0"?>
   <node pkg="navvy_row" name="ransac_row_followerv2" type="ransac_row_followerv2" output="screen">
      <param name="maxRowRatio" value="0.9" /> <!-- Top limit of row detection-->
      <param name="distanceFromRow" value="0.6" />       


I'm not sure I fully understand your question about roscore on the host. I could have roscore running in its own container instead of on the host, either way I wanted a consistent location for the various ros1 containers and ros1-bridge to access.

I'm not sure what else I can provide, but please let me know and I will do my best!

XDGFX gravatar image XDGFX  ( 2021-07-14 03:05:30 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2021-07-14 03:19:16 -0600

XDGFX gravatar image

I think I've found a solution from here.

Adding tty: true seems to solve the problem, and the container starts as expected. I assume for some reason the node is waiting on an interactive shell (which docker-compose doesn't provide) and so won't start. I didn't write the node so not super familiar, but I'll have a look and see if anything suggests it would be waiting for a shell.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2021-07-13 09:17:06 -0600

Seen: 79 times

Last updated: Jul 14