Ask Your Question
0

Unable to override osrf/ros entrypoint

asked 2019-04-05 01:22:54 -0500

arwtyxouymz gravatar image

Hi

This is my first post and I'm very confusing about ROS + docker. What i want to do is to override osrf/ros entrypoints.

The entrypoint's difference is just added to source my workspace's setup.bash. This is my entrypoint.sh

#!/usr/bin/env bash
set -e

# setup ros environment
source "/opt/ros/$ROS_DISTRO/setup.bash"
source "/catkin_ws/devel/setup.bash"

exec "$@"

And I modified Dockerfile to create workspace and build package. This is my Dockerfile

FROM osrf/ros:kinetic-desktop-full

# For Nvidia GPU
ENV NVIDIA_VISIBLE_DEVICES ${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics
RUN apt-get update && apt-get install -y --no-install-recommends \
    libxext-dev libx11-dev x11proto-gl-dev dh-autoreconf\
    && rm -rf /var/lib/apt/lists/ \
    && git clone https://github.com/NVIDIA/libglvnd && cd libglvnd \\
    && ./autogen.sh && ./configure && make -j4 && make install

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
    ros-kinetic-ridgeback-* \
    && mkdir -p /catkin_ws/src && cd /catkin_ws/src \
    && . /opt/ros/kinetic/setup.sh \
    && git clone https://github.com/ridgeback/ridgeback_robot \
    && rosdep install --from-path . -r -y --ignore-src \
    && rm -rf /var/lib/apt/lists/ \
    && cd /catkin_ws && catkin_make

COPY ./entrypoint.sh /
RUN chmod +x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]

CMD ["bash"]

Then, I run docker run -it <myimage>, docker container shutdown immediately. However, If i removed source "/catkin_ws/devel/setup.bash, container will start. So i think /catkin_ws/devel/setup.bash is a problem, but I don't know how to solve it because if i run docker logs <containerID> --details, no logs appeared.

Could someone help me?

I use Ubuntu:18.04 and melodic is installed in my local environment.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-04-05 11:44:19 -0500

Andrew Price gravatar image

The immediate shutdown is coming from the set -e flag in the entrypoint. I'm not sure what the problem with the develspace setup script is, but it happens on both the docker image you sent and the main workspace I'm using for my projects, so the error seems to be pretty pervasive. If someone knows how to error trace a bash script that would be helpful for debugging further, but you can get started by removing the set -e.

edit flag offensive delete link more

Comments

Thank you Andrew!

I removed set -e flag, and succeeded to run a container. But with docker-compose, ros cannot find my local package. This is my docker-compose.yaml

version: '2.3'

services:
  base:
    build: .
    container_name: base
    runtime: nvidia
    privileged: true
    environment:
      - "ROS_HOSTNAME=base"
      - "ROS_MASTER_URI=http://master:11311"
      - "DISPLAY=${DISPLAY}"
      - "QT_X11_NO_MITSHM=1"
    volumes:
      - "/tmp/.X11-unix:/tmp/.X11-unix:rw"
    command: rospack find ridgeback_base

If i executed docker-compose up, base container exited with status code 1 without flag set -e in my entrypoint. However, docker run -it --rm <image name> rospack find ridgeback_base is fine.

What's wrong?

arwtyxouymz gravatar imagearwtyxouymz ( 2019-04-06 04:07:32 -0500 )edit

@arwtyxouymz, that's probably best for another question, and I'm not super familiar with docker-compose. On my machine, running

docker build -f Dockerfile -t ros_answer .
docker run --rm -it ros_answer:latest rospack find ridgeback_base

returns

/catkin_ws/src/ridgeback_robot/ridgeback_base
Andrew Price gravatar imageAndrew Price ( 2019-04-08 12:36:50 -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

2 followers

Stats

Asked: 2019-04-05 01:22:54 -0500

Seen: 112 times

Last updated: Apr 05