osrf / rocker

A tool to run docker containers with overlays and convenient options for things like GUIs etc.
Apache License 2.0
576 stars 75 forks source link

display build errors #35

Open tfoote opened 5 years ago

tfoote commented 5 years ago

When there's a build error the output in rocker is suppressed.

As you can see manually running the command afterwards shows that it's failing due to executable file not found. But the rocker build just ends with an error code and no information. It is an invalid configuration but that doesn't mean we shouldn't show the error message.

$ rocker --home --user hello-world --noex
Plugins found: ['dev_helpers', 'home', 'nvidia', 'pulse', 'user']
Active extensions ['home', 'user']
Writing dockerfile to /tmp/tmpwfb8q_7_/Dockerfile
vvvvvv
# Preamble from extension [home]

# Preamble from extension [user]

FROM hello-world
# Snippet from extension [home]

# Snippet from extension [user]
# make sure sudo is installed to be able to give user sudo access in docker
RUN apt-get update \
 && apt-get install -y \
    sudo \
 && apt-get clean

RUN useradd -U --uid 1000 -ms /bin/bash osrf \
 && echo "osrf:osrf" | chpasswd \
 && adduser osrf sudo \
 && echo "osrf ALL=NOPASSWD: ALL" >> /etc/sudoers.d/osrf
# Commands below run as the developer user
USER osrf

^^^^^^
Building docker file with arguments:  {'path': '/tmp/tmpwfb8q_7_', 'rm': True, 'decode': True, 'nocache': False, 'tag': 'rocker_hello-world_home_user'}
building > Step 1/4 : FROM hello-world
building >  ---> fce289e99eb9
building > Step 2/4 : RUN apt-get update  && apt-get install -y     sudo  && apt-get clean
building >  ---> Running in 6f95c70df683
2 osrf@osrf-toughpad1:~$ docker run -ti --rm 6f95c70df683
Unable to find image '6f95c70df683:latest' locally
docker: Error response from daemon: pull access denied for 6f95c70df683, repository does not exist or may require 'docker login'.
See 'docker run --help'.
125 osrf@osrf-toughpad1:~$ docker run -ti --rm fce289e99eb9 bash
docker: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: \"bash\": executable file not found in $PATH": unknown.
127 osrf@osrf-toughpad1:~$ docker run -ti --rm fce289e99eb9 sh
docker: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: \"sh\": executable file not found in $PATH": unknown.
127 osrf@osrf-toughpad1:~$ docker run -ti --rm fce289e99eb9 

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/
guptaaryan0405 commented 3 years ago

hello sir, I am Aryan Gupta a 1st-year student of Electronics engineering. I am very passionate about robotics and want to contribute to Open Robotics. I am fluent in Python and C. can you help me guide how to start as a beginner.

tfoote commented 3 years ago

Thanks for your interest. This project is mostly used as a development tool and infrastructure that can be used for robotics development.

If you'd like to take a look at this that would be great.

You can find the development environment setup here: https://github.com/osrf/rocker/blob/master/README.md

And with that you should be able to reproduce the above issue.

After that I believe that the docker_build function will need to be extended. https://github.com/osrf/rocker/blob/4f9f6d7595ccc23a2ae9b600a2262deefb676d89/src/rocker/core.py#L135

And hopefully leverage some APIs from the python docker_client API to include the console output in the result stream.

If you have any questions feel free to follow up here.