Skip to content

Commit 19f9295

Browse files
committed
[ADD] improve usability of docker container and docker instructions
1 parent 7f4b891 commit 19f9295

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

docker/Dockerfile.noetic

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,30 @@ RUN apt-get update && apt-get -y --no-install-recommends install \
4444
ros-noetic-vision-msgs \
4545
ros-noetic-visualization-msgs \
4646
ros-noetic-rviz \
47+
# Optionall install RealSense2 package
48+
ros-noetic-realsense2-camera \
4749
&& apt-get -y autoremove \
4850
&& apt-get clean
4951

5052
# Install required Python components
5153
RUN python3 -m pip install -r /tmp/requirements.txt
5254

53-
# Source ROS noetic
55+
# Copy and set up the ros_entrypoint.sh
56+
COPY ./docker/ros_entrypoint.sh /ros_entrypoint.sh
57+
RUN chmod +x /ros_entrypoint.sh
58+
59+
# Make sure the catkin workspace is initialized
5460
RUN . /opt/ros/noetic/setup.sh && \
55-
./tmp/init_workspace.sh
61+
/tmp/init_workspace.sh
62+
63+
# Set the entrypoint to ros_entrypoint.sh
64+
ENTRYPOINT ["/ros_entrypoint.sh"]
65+
66+
# Default command
67+
CMD ["bash"]
5668

57-
# Set Display variables
69+
# Set Display variables for GUI applications
5870
ENV DISPLAY=:0
5971
ENV TERM=xterm
6072
# Some QT-Apps do not show controls without this
61-
ENV QT_X11_NO_MITSHM=1
73+
ENV QT_X11_NO_MITSHM=1

docker/ros_entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
# Source ROS distribution and Catkin Workspace
4+
source /opt/ros/noetic/setup.bash
5+
source ${DEVEL}/setup.bash
6+
7+
exec "$@"

docs/DOCKER.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ This will take several minutes and require connection to the internet. This comm
3030
- `name` specifies the name of the image. By default, it is `trackdlo`. Multiple containers can be created from the same image by changing this parameter.
3131
- `host dir` and `container dir` map a directory on the host machine to a location inside the container. This enables sharing code and data between the two systems. By default, the `run_docker.sh` bash script maps the directory containing trackdlo to `/root/tracking_ws/src/trackdlo` in the container.
3232

33-
Only the first call of this script with a given name will create a container. Subsequent executions will attach to the running container to enable running multiple terminal sessions in a single container.
33+
Only the first call of this script with a given name will create a container. Subsequent executions will attach to the running container to enable running multiple terminal sessions in a single container. In subsequent calls, please check that ROS and the built catkin workspace are properly sourced.
34+
35+
```
36+
source /ros_entrypoint.sh
37+
```
3438
3539
*Note:* Since the Docker container binds directly to the host's network, it will see `roscore` even if running outside the docker container.
3640

0 commit comments

Comments
 (0)