This setup guide provides step-by-step instructions for running ROS1 Noetic in a Docker container, specifically designed for replaying ROS bags in a containerized ROS workspace.
Ensure you have the following software installed on your machine:
Create the workspace directory structure on your machine:
mkdir -p ~/dv_ws_ros1/src
Clone your ROS workspace into the src
directory:
git clone <your-repo-url> ~/dv_ws_ros1/src
Create a directory for your ROS bag files and add your ROS bags:
mkdir ~/rosbag1
cp path/to/your/bag1.bag ~/rosbag1/
Ensure the start.sh
script references your ROS bag files correctly.
- Open the
start.sh
file:nano ros1_docker/start.sh
- Update the line referencing the ROS bag file to:
rosbag play /home/rosbag1/bag1.bag -l &
If you would like to launch different nodes, modify the "Launch the ROS node" section in the start.sh
file. The container will automatically execute the start.sh
script to set up the ROS environment and replay the specified ROS bag. Adjust start.sh
as needed to fit your requirements.
To build and start the Docker container, use the following commands:
- If you are building the image for the first time or after making changes:
docker compose up --build
- If the image is already built and you only need to start the container:
docker compose up
-
ROS Bag Playback Issues:
- Verify that your
start.sh
script correctly points to the bag file location:/home/rosbag1/bag1.bag
. - Confirm that the bag files are present in the
~/rosbag1
directory.
- Verify that your
-
Problems Running
docker-compose up --build
:- If you encounter build or run errors, clean up unused Docker containers with:
docker container prune
- Then, rebuild and run the container:
docker compose up --build
- If you encounter build or run errors, clean up unused Docker containers with:
-
RViz Not Launching:
- Try accessing the Docker shell and starting RViz manually:
docker exec -it ros_container bash rviz
- Try accessing the Docker shell and starting RViz manually:
-
Accessing the Docker Shell:
- To interact with the running container's shell, open a new terminal window and run:
xhost +local:docker # Grants Docker access to your X11 server for GUI applications docker exec -it ros_container bash # Access the container's shell
- Once inside the container, you can run commands like
rviz
. To exit the container shell, simply type:exit
- To interact with the running container's shell, open a new terminal window and run:
-
Cleaning Up Unused Docker Images:
- To list existing images, run:
docker images
- To remove unused images:
docker rmi <image-id>
- To list existing images, run: