OpenAg Wiki Archive
Archived Contents from the original OpenAg Wiki (snapshot on Apr 8, 2020)
The archived wiki only includes information up the v3.0 version of the PFC-EDU, and is here for preservation purposes. You can find resources about the latest version of the PFC v4.0 on the Personal Food Computer resources page.
Docker
The OpenAg system runs within 2 Docker containers:
one for the openag_brain ROS system, and one for CouchDB.
docker-compose
coordinates between the 2 containers.
See docs.docker.com for detailed Docker documentation.
Handy Docker commands
See which containers are running:
docker ps
The Docker install script creates and runs 2 docker containers. You should see them listed when running docker ps:
openagbraindockerrpi_brain_1
openagbraindockerrpi_db_1
Stoping and starting the containers is done in the usual way:
docker-compose start
docker-compose stop
docker-compose restart
You can get logs for the containers via docker’s logging command:
docker logs -f openagbraindockerrpi_brain_1
Running commands in containers
You can run bash commands within a container with docker exec
:
docker exec <container> <command>
For example:
docker exec openagbraindockerrpi_brain_1 rosrun openag_brain load_fixture default
“Shelling into” running containers
OpenAg Brain is powered by ROS. Sometimes, you might want to interact with ROS in the Docker container directly. To do so, first shell into the Docker container:
docker exec -it openagbraindockerrpi_brain_1 bash
Then, activate the catkin workspace within the Docker container:
source catkin_ws/devel/setup.bash
Now, you can interact with ROS. For more, see ros.
Note that Docker containers are stateless, so if your Docker container restarts, it will lose the changes you make. If you need the changes to stick, build a new Docker image (see below).
Building new Docker images
If you’re contributing to openag_brain,
you might want to build new Docker images. To build new Docker images
from , you’ll want to install the Docker command line
tools. Running the install_docker.sh
script from
openag_brain_docker_rpi
on your Raspberry Pi will take care of installing these for you.
Once Docker is installed, building images is easy. Just:
cd ~/catkin_ws/src/openag_brain
and
docker build -t openag/rpi_brain .
You can provide your own tag/name in place of openag/rpi_brain. See Docker’s docs on the build command for more.
Note: we’ve had trouble with Raspbian’s Pixel desktop freezing while building Docker images. We’ve also had problems with Docker builds failing on Rasberry Pi 2 when no swapfile is configured. We recommend the following build setup for best results:
- Use a Raspberry Pi 3
- Make sure to configure a swapfile
- Use Raspbian Jesse Lite (not the Desktop version)
- ssh into your Pi and start the build over ssh
Exposing USB Devices
Docker containers are isolated from the host environment by default. For a container to communicate with USB devices, you have to give them explicit access to the device.
With docker-compose, this is done using by adding the devices
key to
your service in docker-compose.yml
:
...
services:
brain:
devices:
- "/dev/ttyACM0:/dev/ttyACM0"
...
You may also need to add the privileged
key to the
service.
If running the container via docker run
, you can use the device
flag
to explicitly expose host devices to the container.
Resources:
- https://docs.docker.com/engine/reference/commandline/run/
- http://stackoverflow.com/questions/24225647/docker-any-way-to-give-access-to-host-usb-or-serial-device