ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

How to RUN rosdep init and update in Dockerfile

asked 2016-08-04 15:12:21 -0500

spmaniato gravatar image

updated 2016-08-04 16:35:03 -0500

What's the correct way of running sudo rosdep init followed by rosdep update in a Dockerfile?

Looking at OSRF's indigo-ros-core Dockerfile, there's a simple:

RUN rosdep init \
    && rosdep update

However, running rosdep update like that in my own Dockerfile results in a warning, since it was essentially run with sudo. In turn, this results in rosdep install not finding dependencies later on.

So, since I'll be running this Docker image on a Raspberry Pi 3, I've been trying the Docker-raspbian-ros-indigo Dockerfile, which sets up a new user, pi, and then runs the rosdep commands as that user (see link for details).

RUN sudo rosdep init
RUN rosdep update

But trying to build my Dockerfile like that gives me the following error message:

Step 12 : RUN sudo rosdep init
---> Running in d10888b83a25
sudo: effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges?

I also tried the trick from osblinnikov/ros-docker. In a nutshell:

RUN adduser --gecos "ROS User" --disabled-password ros
RUN usermod -a -G dialout ros
USER ros
RUN HOME=/home/ros rosdep update
# ...
RUN rosdep install --from-paths src --ignore-src --rosdistro $ROS_DISTRO -y

However, the rosdep install commands fails with:

Step 20 : RUN rosdep install --from-paths src --ignore-src --rosdistro $ROS_DISTRO -y
 ---> Running in 3be8cdf3c72a
sudo: no tty present and no askpass program specified
ERROR: the following rosdeps failed to install
  apt: command [sudo -H apt-get install -y python-mock] failed
executing command [sudo -H apt-get install -y python-mock]
The command '/bin/sh -c rosdep install --from-paths src --ignore-src --rosdistro $ROS_DISTRO -y' returned a non-zero code: 1

Update: This last error was resolved by:

  • letting the ros user execute commands as sudo without password (ros ALL=(ALL) NOPASSWD: ALL)
  • and also adding RUN sudo apt-get update before rosdep install in order to update the package lists
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-08-04 16:33:16 -0500

tfoote gravatar image

If you're doing all of this in the Dockerfile it's recommended to run everything as root.

There's no point in changing the user to pi then using sudo to run the command with super user privlages. You only want to drop into the pi user shortly before you finish the Dockerfile and provide the entrypoint.

edit flag offensive delete link more



Thanks for the quick reply Tully. So, I guess it's OK to ignore Warning: running 'rosdep update' as root is not recommended. in a Dockerfile? Looks like it worked so no complaints here :-)

spmaniato gravatar image spmaniato  ( 2016-08-04 17:17:41 -0500 )edit

If you run rosdep update as root only root will have access to the database. This is typically a problem if people run sudo rosdep update then try to run rosdep install at which time root has the db, but the USER does not. In this case you are going to run rosdep install as root. So it's fine.

tfoote gravatar image tfoote  ( 2016-08-04 18:01:55 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-08-04 15:12:21 -0500

Seen: 3,109 times

Last updated: Aug 04 '16