ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Ship a ROS package with Docker

asked 2017-04-19 17:21:24 -0600

updated 2017-04-29 23:00:52 -0600

Hi everyone,

I have a ROS package which has been well-tested with Caffe and Tensorflow + Cuda. It is quite a burden explaining to users how to use this package and I feel it is best to ship it to users as a docker image. Now, on the docker hub, I see osrf/ros images for example, indigo as well as gazebo (which btw are dependencies for this project).

I have created the dockerfile as well as built the docker image but I find that the ros environment within the docker build is not active. I cannot catkin_init_workspace, catkin build nor catkin make. For the record, I pulled the OSRF/ros_indigo image in building my ros environment. There is no ros installation path in /opt/ros/... either.

The instructions are scarce and I wonder what I may be doing wrong.

Would appreciate your help.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-04-20 02:34:12 -0600

rbbg gravatar image

I think you are making a mistake in your Dockerfile. You cannot layer docker images the way you have tried.

I believe that when you have:

FROM ros:indigo-ros-core
LABEL maintainer ""

# install ros packages
RUN apt-get update && apt-get install -y \
    ros-indigo-ros-base=1.1.4-0* \
    && rm -rf /var/lib/apt/lists/*

# Install gazebo
FROM gazebo:gzserver6

FROM ubuntu:trusty

The image will actually only use ubuntu:trusy and 'forget' about the things you did before. You are probably best of starting from the image that has most of what you want, and then install the rest on top of it (using apt) it's a bit of a hassle, but I recently created a CUDA enabled trusty-ros-indigo-moveit image this way and it worked fine. I have removed a couple of things so not entirely certain but I think it should work like this. The entrypoint is the same as the one from indigo-ros-core.

FROM nvidia/cuda:8.0-devel-ubuntu14.04
# setup environment
RUN locale-gen en_US.UTF-8

# setup sources.list
RUN echo "deb trusty main" > /etc/apt/sources.list.d/ros-latest.list

# install bootstrap tools
RUN apt-get update && apt-get install --no-install-recommends -y \
    python-rosdep \
    python-rosinstall \
    python-vcstools \
    && rm -rf /var/lib/apt/lists/*

# bootstrap rosdep
RUN rosdep init \
    && rosdep update

# install ros packages
RUN apt-get update && apt-get install -y \
    ros-indigo-desktop-full=1.1.4-0* \
    && rm -rf /var/lib/apt/lists/*

# setup entrypoint
COPY ./ /

CMD ["bash"]

# ros-indigo-ros-base
RUN apt-get update && apt-get install -y \
    ros-indigo-ros-base=1.1.4-0* \
&& rm -rf /var/lib/apt/lists/*

# moveit-indigo-ci
ENV TERM xterm

# Setup catkin workspace
ENV CATKIN_WS=/root/ws_moveit
RUN mkdir -p $CATKIN_WS/src

# Commands are combined in single RUN statement with "apt/lists" folder removal to reduce image size
RUN wstool init . && \
    # Download moveit source so that we can get necessary dependencies
    wstool merge${ROS_DISTRO}-devel/moveit.rosinstall && \
    wstool update && \
    # Update apt-get because previous images clear this cache
    apt-get -qq update && \
    # Install some base dependencies
    apt-get -qq install -y \
        # Required for rosdep command
        sudo \
        # Required for installing dependencies
        python-rosdep \
        # Preferred build tool
        python-catkin-tools \
        # Not sure if necessary:
        ros-$ROS_DISTRO-rosbash \
        ros-$ROS_DISTRO-rospack && \
    # Download all dependencies of MoveIt!
    rosdep update && \
    rosdep install -y --from-paths . --ignore-src --rosdistro ${ROS_DISTRO} --as-root=apt:false && \
    # Remove the source code from this container. TODO: in the future we may want to keep this here for further optimization of later containers
    cd .. && \
    rm -rf src/ && \
    # Clear apt-cache to reduce image size
    rm -rf /var/lib/apt/lists/*

# Continous Integration Setting

# moveit-indigo-release
RUN apt-get update && \
    apt-get install -y \
        ros-${ROS_DISTRO}-moveit-* && \
rm -rf /var/lib/apt/lists/*

Hope this helps.

edit flag offensive delete link more


Thanks. I will try this. Where is this Dockerfile domiciled? I need to find the file Thanks

lakehanne gravatar image lakehanne  ( 2017-04-23 16:00:40 -0600 )edit

It's an extract of a bigger Dockerfile so I haven't tested this exact file and it's online. The entrypoint can be found here. good luck.

rbbg gravatar image rbbg  ( 2017-04-24 02:38:58 -0600 )edit

Thanks. May I ask why you installed ros-indigo from source and also pulled ros-indigo-ros-base=1.1.4-0* in the same dockerfile? I just finished building my caffe image with your nvidia/cuda:8.0-devel-ubuntu14.04, ros-indigo-full and ros-indigo-base and I found that my build is about 3GB.

lakehanne gravatar image lakehanne  ( 2017-04-25 10:32:28 -0600 )edit

He, looks like I have some duplicate parts in there :) Pretty sure that's an error. I copied most from Dockerfiles from osrf and MoveIt! and didn't carefully inspect everything, so that's probably how it got in there. The image does get quite large but at least in my case it couldn't be helped.

rbbg gravatar image rbbg  ( 2017-04-28 00:43:07 -0600 )edit

Okay. Thanks for the clarification. I have cleaned it up and my dockerfile is here. Thank you!

lakehanne gravatar image lakehanne  ( 2017-04-28 18:10:49 -0600 )edit

BTW, how did you compile your cuda-8.0? From .deb or via the .run file? I couldn't get my image to populate a matplotlib window as I wanted when I run the docker image with DISPLAY support.

lakehanne gravatar image lakehanne  ( 2017-04-28 18:14:26 -0600 )edit

I have removed the second ros-indigo-base install file and it's lesser in bytes. Thanks for your help though.

lakehanne gravatar image lakehanne  ( 2017-04-29 23:02:14 -0600 )edit

Question Tools

1 follower


Asked: 2017-04-19 17:21:24 -0600

Seen: 2,960 times

Last updated: Apr 29 '17