Skip to content

Commit

Permalink
[ADD] improve usability of docker container and docker instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
hollydinkel committed Feb 7, 2025
1 parent 7f4b891 commit 19f9295
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
20 changes: 16 additions & 4 deletions docker/Dockerfile.noetic
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,30 @@ RUN apt-get update && apt-get -y --no-install-recommends install \
ros-noetic-vision-msgs \
ros-noetic-visualization-msgs \
ros-noetic-rviz \
# Optionall install RealSense2 package
ros-noetic-realsense2-camera \
&& apt-get -y autoremove \
&& apt-get clean

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

# Source ROS noetic
# Copy and set up the ros_entrypoint.sh
COPY ./docker/ros_entrypoint.sh /ros_entrypoint.sh
RUN chmod +x /ros_entrypoint.sh

# Make sure the catkin workspace is initialized
RUN . /opt/ros/noetic/setup.sh && \
./tmp/init_workspace.sh
/tmp/init_workspace.sh

# Set the entrypoint to ros_entrypoint.sh
ENTRYPOINT ["/ros_entrypoint.sh"]

# Default command
CMD ["bash"]

# Set Display variables
# Set Display variables for GUI applications
ENV DISPLAY=:0
ENV TERM=xterm
# Some QT-Apps do not show controls without this
ENV QT_X11_NO_MITSHM=1
ENV QT_X11_NO_MITSHM=1
7 changes: 7 additions & 0 deletions docker/ros_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Source ROS distribution and Catkin Workspace
source /opt/ros/noetic/setup.bash
source ${DEVEL}/setup.bash

exec "$@"
6 changes: 5 additions & 1 deletion docs/DOCKER.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ This will take several minutes and require connection to the internet. This comm
- `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.
- `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.

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.
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.

```
source /ros_entrypoint.sh
```
*Note:* Since the Docker container binds directly to the host's network, it will see `roscore` even if running outside the docker container.
Expand Down

0 comments on commit 19f9295

Please sign in to comment.