ros-industrial / docker

ROS-Industrial docker and cloud tools
23 stars 21 forks source link

No sudo in rosindustrial/ci:kinetic-xenial image #25

Closed 130s closed 6 years ago

130s commented 6 years ago

Not even sure if this is a problem or not but I see sudo is available in Trusty image but not in Xenial:

$ docker run -it rosindustrial/ci:indigo-trusty 
root@16bb97a2cc7c:/# sudo ls
bin   dev  home  lib64  mnt  proc  run   srv  tmp  var
boot  etc  lib   media  opt  root  sbin  sys  usr
root@16bb97a2cc7c:/# exit
exit
$ docker run -it rosindustrial/ci:kinetic-xenial 
root@c03f6417b57a:/# sudo ls
bash: sudo: command not found
root@c03f6417b57a:/# exit
exit
$ docker images | grep -i "rosindustrial/ci"
rosindustrial/ci                                                   kinetic-xenial                                  510c9238c326        4 weeks ago         546MB
rosindustrial/ci                                                   indigo-trusty                                   435a55d3c7da        4 weeks ago         490MB
130s commented 6 years ago

(Not an official reference but) according to https://github.com/tianon/docker-brew-ubuntu-core/issues/48 sudo doesn't come with the "minimal set of packages".

Is this something we want to resolve in this repo or downstream?

130s commented 6 years ago

Absense of sudo might not matter on online CI services where each job runs as root, so this might be an issue when one wants to run docker build on a local computer.

Still, I want to know where's the best place to implement a workaround to this.

gavanderhoorn commented 6 years ago

sudo in a Docker image seems a bit strange to me: unless a different user has been explicitly added to the container, you'll be root.

I don't see a new user added to the images in this repository. @130s: what do you require sudo for?

mathias-luedtke commented 6 years ago

I agree with @gavanderhoorn (I am sure that I have written a comment 2 weeks ago, but somehow it did not make it here)

so this might be an issue when one wants to run docker build on a local computer.

By default docker build runs all command as root, but without any mounts, so what's the issue here? (The user can be overwritten by the USER directive only)

130s commented 6 years ago

I might be doing something wrong, but with the following simple Dockerfile,

FROM rosindustrial/ci:kinetic-xenial
RUN sudo rosdep init; rosdep update
$ docker build -f ./Dockerfile -t foo_image .
:
Step 2/2 : RUN sudo rosdep init; rosdep update
 ---> Running in d38e9949c654
/bin/sh: 1: sudo: not found
ERROR: no sources directory exists on the system meaning rosdep has not yet been initialized.

Please initialize your rosdep with

        sudo rosdep init

The command '/bin/sh -c sudo rosdep init; rosdep update' returned a non-zero code: 1

apt-get install sudo works this around.

gavanderhoorn commented 6 years ago

RUN sudo rosdep init; rosdep update

I might be misunderstanding you, but you don't need sudo there.

Everything in the Docker build sequence is run as root, unless you explicitly change it to not do that.

130s commented 6 years ago

Ok, so, in Dockerfile I don't need sudo (regardless the platform the file is intended for). Thanks for the inputs @gavanderhoorn @ipa-mdl