1 Run platypush in a container
Fabio Manganiello edited this page 2018-12-19 23:11:31 +01:00

A very robust and scalable way to run Platypush is to build a Docker container image out of it.

The project comes with platydock, that will be installed in your prefix upon Platypush installation. You can use it to build, remove, start, stop and list Platypush container images. Note that both docker and platypush need to be installed on your host system for these steps to work.


  1. Create your own config.yaml file for a Platypush instance:
    # NOTE: It's mandatory to specify a device_id when building
    # a Platypush container. Containers will have their hostname
    # dynamycally set by Docker and therefore won't be a reliable default

    # Log to container stdout/stderr
    level: INFO

    engine: sqlite:////usr/local/share/platypush/platypush.db

    token: YOUR_TOKEN
    device: platypush/your_device

    # Redis and Platypush can't run in the same Docker container, but platydock will
    # take care of pulling a Redis docker image and connect it to your container.
        host: redis

    host: YOUR_MQTT_HOST

    port: 3333

    port: 8765

    port: 8008

    host: redis

    language: en-US

    ifttt_key: YOUR_IFTTT_KEY

            key: KEY_1
            key: KEY_2
  1. Build a Docker image out of the configuration file using platydock:
platydock build -c /path/to/config.yaml

Note that platydock will inspect your configuration file and automatically identify required dependencies and exposed ports.

  1. Start the new image:
platydock start my-image
  1. After it's started up, if everything went smooth, you should already be able to send messages to the new container over the available exposed service. For example, over JSON-RPC:
curl -XPOST -H 'Content-Type: application/json' \
    -d '{"type":"request", "action":"shell.exec", "args": {"cmd":"hostname"}}' \
    http://localhost:8008/execute | jq

You can also easily inspect the application logs:

docker logs my-image

And you can also pass extra options to platydock start, that will be transparently passed to docker run, for instance --add-host=, --device= etc. Note that the exposed ports are automatically added to the container based on the configuration and by default will be exposed to the same port number on the host (e.g. 8008 on the container is published to 8008 on the host). You can override it through the -p option passed to platypush start (e.g. -p 18008:8008 will map the port 8008 on the container to 18008 on the host).

Also note that platypush start will start both your Platypush container and the support Redis container.

  1. Check the installed Platypush images:
platydock ls [filter]
  1. Stop a running instance:
platydock stop my-image
  1. Remove an image:
platydock rm my-image