111763 Views
85221 Views
83639 Views
51774 Views
49949 Views
48472 Views
Obsidian - the best tool for Makers
10 Projects for your Raspberry Pi Pico
Raspberry Pi Telegraf Setup with Docker
Setting Up Dynamic DNS on a Raspberry Pi for Self-Hosting
Raspberry Pi WordPress Setup with Docker
Raspberry Pi WireGuard VPN Setup with Docker
Using the Raspberry Pi Pico's Built-in Temperature Sensor
Getting Started with SQL
Introduction to the Linux Command Line on Raspberry Pi OS
How to install MicroPython
Wall Drawing Robot Tutorial
BrachioGraph Tutorial
KevsRobots Learning Platform
40% Percent Complete
By Kevin McAleer, 2 Minutes
To make the process of building our ROS2 container simpler I have created a dockerfile and accompanying docker-compose.yml file. These two files help us build and then run the ROS2 docker container.
dockerfile
docker-compose.yml
Docker-Compose.yml The docker-compose.yml file contains instructions on which docker image to use and also any parameters we want to include, such as host device (we’ll want to use the lidar sensor which is found at /dev/ttyUSB0 on the host file system), and also any volume or folder mappings. Contents of the docker-compose.yml version: "3.9" services: ros2: build: . # restart: no ports: - "3332:3332" volumes: - /home/kev/ros:/home/ros - /home/kev/cubie-1:/ros2 devices: - /dev/ttyUSB0:/dev/ttyUSB0 tty: true Folder mappings We can map local folders from our Raspberry Pi into our container so that any files we create inside or out of the container will show up. Normally any changes made within the container are lost when we shut it down, however by mapping (called binding in Docker) the local host folder to the container we can ensure changes are retained. We will map two host folders: /home/kev/ros to /home/ros within the container /home/kev/cubie-1 to /ros2 within the container
The docker-compose.yml file contains instructions on which docker image to use and also any parameters we want to include, such as host device (we’ll want to use the lidar sensor which is found at /dev/ttyUSB0 on the host file system), and also any volume or folder mappings.
/dev/ttyUSB0
Contents of the docker-compose.yml
version: "3.9" services: ros2: build: . # restart: no ports: - "3332:3332" volumes: - /home/kev/ros:/home/ros - /home/kev/cubie-1:/ros2 devices: - /dev/ttyUSB0:/dev/ttyUSB0 tty: true
We can map local folders from our Raspberry Pi into our container so that any files we create inside or out of the container will show up. Normally any changes made within the container are lost when we shut it down, however by mapping (called binding in Docker) the local host folder to the container we can ensure changes are retained.
binding
We will map two host folders:
/home/kev/ros to /home/ros within the container
/home/kev/ros
/home/ros
/home/kev/cubie-1 to /ros2 within the container
/home/kev/cubie-1
/ros2
cd cubie-1/docker
docker build -t ros2 .
Where ros2 is the name of the docker image we have created
ros2
docker-compose up -d
The container will now be running, you can check to see if its running using the docker ps command.
docker ps
< Previous Next >