Monthly Archives: February 2018

Accessing gpio pins inside a docker container on a raspberry pi

If your container needs access to the GPIO pins, then it must have access to the /dev/gpiomem device. From the command line you can do that like this:

$ docker run --device=/dev/gpiomem:/dev/gpiomem ...rest of commandline...

Here’s how to do it with a docker-compose file:

version: "2"

services:
  app:
    devices:
      - /dev/gpiomem:/dev/gpiomem
    ports:
     ...rest of the file...