osrf / docker_images

A repository to hold definitions of docker images maintained by OSRF
Apache License 2.0
578 stars 172 forks source link

roscore & roslaunch logs won't show until container stops #665

Closed niconiconi1234 closed 1 year ago

niconiconi1234 commented 1 year ago

Hello. I'm using ros:noetic image and meet a strange problem. When I try to start roscore in container, the log (i.e output of roscore ) won't show until I use ctrl+c to stop the container. Before I press ctrl+c, nothing shows, but roscore in container is running

image image

After I press ctrl+c, the output of roscore shows

image

What expect to happen Output of roslaunch shows immediately after launching the container, instead of after terminating the container Environment Image: ros:noetic Host System: macos 13.2.1 Docker Version: Docker Engine 20.10.22 Same problem for ros:noetic Ubuntu 20.04 arm64 and docker 20.10.23

Am I doing something wrong?

niconiconi1234 commented 1 year ago

I found I should use -t tag. docker run --rm -t ros:noetic bash -c "source /opt/ros/noetic/setup.bash && roscore" this works.

ruffsl commented 1 year ago

Another thing you may want to watch out for is python's default buffering and docker's stdout stream capture. Note the use of PYTHONUNBUFFERED=1 for the environment in the Docker Compose example in the docker library documentation for ROS: