We need to use docker-machine to handle USB ports inside the docker.
- Install docker-machine: https://docs.docker.com/machine/install-machine/
- Docker version: 18.09.2, build 6247962
- Install virtualbox >= 6.0
Follow this gist: https://gist.github.com/stonehippo/e33750f185806924f1254349ea1a4e68 to setup USB to be visible inside the container.
docker pull ros:latest
Following the guide : https://docs.docker.com/samples/library/ros/
docker network create ros-network
docker run -it --rm --net ros-network --name=roscore ros:latest roscore
Command with debug support:
docker run -it --rm \
--security-opt seccomp:unconfined \
--net ros-network \
-p 9091:9091 \
--device=/dev/ttyUSB0 \
-v $PWD:/home/project \
--name=$container_name \
--workdir=/home/project \
$image_name /bin/bash
Install it from : https://www.xquartz.org/
Configure following: https://sourabhbajaj.com/blog/2017/02/07/gui-applications-docker-mac/
-
https://sourabhbajaj.com/blog/2017/02/07/gui-applications-docker-mac/#run-xquartz
-
get host IP:
ifconfig en0 | grep inet | awk '$1=="inet" {print $2}'
-
defaults write org.macosforge.xquartz.X11 enable_iglx -bool true
IP=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')
xhost +${IP}
docker run --rm \
--env="DISPLAY=192.168.5.43:0" \
--volume="$HOME/.Xauthority:/root/.Xauthority:rw" \
--net ros-network \
--env ROS_MASTER_URI=http://roscore:11311 \
--name=rviz \
ros_rviz:latest rviz
Hello, once I degrade to Xquartz 2.7.8, rviz was running successfully but now crash again,but other 3d viewers are runing well.