Docker Community Forums

Share and learn in the Docker community.

Bug in Printing to Console using ROS_INFO

docker

(Nathangeorge2) #1

Problem description

I think there is a bug in how docker prints information to terminal, at least with respect to ROS_INFO. For a simple ROS HelloWorld program that uses just ROS_INFO, the message isn’t printed; but if I add a cout message, then both print. The fact that ROS_INFO prints if cout is present leads me to believe this isn’t a ROS bug.

Relevant info:

Dockerfile

FROM ros:kinetic

docker-compose.yml

version: '2'

services:
    master:
        build: .
        container_name: master
        command: roscore

    t1:
        build: .
        container_name: t1
        environment:
            - "ROS_HOSTNAME=t1"
            - "ROS_MASTER_URI=http://master:11311"
        volumes:
            - ~/catkin_ws:/repo
        command: /repo/docker-command.sh

docker-command.sh

#!/bin/bash

# wait for roscore
sleep 2 						# at least 2

cp -r /repo/devel/lib/trial /opt/ros/kinetic/lib
source /ros_entrypoint.sh
rosrun trial HelloWorld

# don't stop container
while true; do sleep 1000; done

HelloWorld.cpp

#include <ros/ros.h>

using namespace std;

int main(int argc, char** argv) {
	ros::init(argc, argv, "trial");
	
	ROS_INFO("Hello World!");
	cout << "Hello World 2!" << endl;

	ros::spin();
	return 0;
}

Output with only ROS_INFO print (commenting the line cout << "Hello World 2!" << endl;)

nathan@nathan-ma-vm1:~/catkin_ws$ docker-compose up
Starting master
Starting t1
Attaching to t1, master
t1        | [rospack] Error: package 'trial' not found
t1        | find: ‘’: No such file or directory
^CGracefully stopping... (press Ctrl+C again to force)

Output with both prints

nathan@nathan-ma-vm1:~/catkin_ws$ docker-compose up
Starting master
Starting t1
Attaching to master, t1
t1        | [rospack] Error: package 'trial' not found
t1        | find: ‘’: No such file or directory
t1        | [ INFO] [1524672395.044437305]: Hello World!
t1        | Hello World 2!
^CGracefully stopping... (press Ctrl+C again to force)

(Nathangeorge2) #2

anyone can answer this?