How to run ROS on OSX with Docker

If you really love Mac OS

Posted by Steven on August 7, 2018

Docker is a very convenient and easy to use container tool. I recently figured out how it works and set up a ROS image with it. Now I can use ROS in the comfort of a familiar Mac OS setup!

Instructions

  • Download and install Docker from Docker’s website
  • Pull a ROS image, a list is here
      $ docker pull ros:kinetic-robot-xenial
    
  • Run ROS container
      $ docker run -it ros:kinetic-robot-xenial
    

    This opens an interactive session with the running container. From here, we need to run roscore. Now there is a problem - our terminal session is consumed by roscore! To solve this, open a new terminal session and:

$ docker ps -l
$ docker exec -it <CONTAINER-ID-FROM-ABOVE> bash

This allows us to open addition bash sessions within the same container. Don’t forget to source ROS’s setup after this:

source /opt/ros/kinetic/setup.bash
  • Stopping ROS containers To stop the containers, simply stop the original processes run by the docker run command. CTRL-C and then exit will do the trick.

References

Docker Website
Official Docker images repository
ROS Docker Tutorial
Where Are Docker Images Stored?