DockerfileでROS indigo環境を作る

やりたいこと

Ubuntu 18.04上で、ROS indigoが動く環境をDockerfileを使って作る。

Ubunu 18.04上の環境

1
2
3
4
5
6
7
~/catkin_ws
├── build
├── devel
├── Dockerfile
└── src
├── test_pkg
└── test_pkg.tgz

Dockerfile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
FROM osrf/ros:indigo-desktop-full

RUN mkdir -p /home/catkin_ws/src && \
cd /home/catkin_ws/src && \
/bin/bash -c "source /opt/ros/indigo/setup.bash; /opt/ros/indigo/bin/catkin_init_workspace" && \
cd /home/catkin_ws && \
/bin/bash -c "source /opt/ros/indigo/setup.bash; catkin_make" && \
echo "source /opt/ros/indigo/setup.bash" >> ~/.bashrc && \
echo "source /home/catkin_ws/devel/setup.bash" >> ~/.bashrc

RUN apt-get update && apt-get install -y \
ros-indigo-jsk-visualization \
ros-indigo-tf-conversions \
ros-indigo-pcl-ros

COPY src/test_pkg.tgz /home/catkin_ws/src/

WORKDIR /home/catkin_ws/src
RUN tar xzvf test_pkg.tgz && cd /home/catkin_ws && \
/bin/bash -c "source /opt/ros/indigo/setup.bash; catkin_make; source /home/catkin_ws/devel/setup.bash"

Build

1
2
cd ~/catkin_ws
docker build -t <image_name>:<tag> .

Run

1
docker run -it --net=host indigotest:0.1 bash

--net=hostオプションが重要。

参考リンク