Skip to content

3. Using Docker to run application

SamVanderstraeten edited this page Jan 19, 2023 · 12 revisions

Using Docker

Using docker to run the application is easy. It will automatically create the containers that contain all necessary components. But first, you'll need to install docker and docker-compose on your RPi.

Connect to your RPi (using SSH) and follow the steps below.

Install docker & docker-compose

You can install docker using the following script:

curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh

Another option is installing docker by following the instructions at the official docker site.

After installation, execute the following script to give your user rights to run docker without sudo:

sudo usermod -aG docker pi

Logout completely and log back in. Then you should be able to perform the following: docker ps

It's okay if no containers are shown at this moment.

Install docker-compose

Start with installing prereqs

sudo apt-get install -y libffi-dev libssl-dev python3-dev python3 python3-pip

After this you can install docker-compose:

sudo apt install docker-compose

Install development tools :

sudo apt-get install -y build-essential git

Clone the repository

Clone the rttf-edgecar repo in a new folder so we can get going!

mkdir -p ~/projects && \
  cd ~/projects && \
  git clone https://github.com/PXLDigital/rttf-edgecar && \
  cd rttf-edgecar 

Build Docker images

cardrivers

This container will be responsible for providing all kinds of data about the car. (wheels, engine, camera, ...)

Build the cardrivers image by executing the following command in the rttf-edgecar folder:

cd cardrivers && docker build -t cardrivers:latest .

pi-comm

This container hosts a webpage from which a few actions can be managed to control the car.

Build the pi_comm image by executing the following command in the rttf-edgecar folder:

cd pi-comm && docker build -t pi_comm:latest .

aidrivingmodule

This container will be automatically built and added during the next steps. Nothing must be done at this moment.

docker-compose

Once the images are ready and the scripts are available, you can boot up everything by running the following command in the rttf-edgecar folder:

docker-compose up -d

Afterwards, you can execute docker ps -a. You should see something like this:

rttf@raspberrypi:~/Projects/rttf-edgecar $ docker ps -a

CONTAINER ID   IMAGE                                   COMMAND                  CREATED         STATUS                  PORTS     NAMES
28535437ab25   pi_comm                                 "python3 /home/user/…"   7 seconds ago   Up 4 seconds                      rttf-edgecar_pi-comm_1
2d053cfc49d6   enicky/aidrivingmodule:latest-arm32v7   "/ros_entrypoint.sh …"   7 seconds ago   Up Less than a second             rttf-edgecar_aidrivingmodule_1
27fc270d9a9a   cardrivers:latest                       "/ros_entrypoint.sh …"   8 seconds ago   Up 7 seconds                      rttf-edgecar_cardrivers_1

Next steps

You should be able to control your car now. Continue to: