Docker Compose first steps

Hi,

I use rhasspy master/satellite with Docker. And know nothing about docker compose !
As my rhasspy setup is now in production ( :tada: ) and just receive a new Pi4 to test future versions and try different thing, I would have a look at it.

I get the abstract, creating a yml file with all settings inside, instead of running docker with plenty or params for devices, volumes, ports etc.

installation

Is there a better install cmd line to get latest stable compose version on a Pi/Buster ? I see different one with version into …

example:

sudo curl -L "https://github.com/docker/compose/releases/download/1.28.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

setting

I see every settings goes into docker-compose.yml.
So, I guess we can’t rename this file ? And where goes this file ? Do you let it in /home/pi ?
Or do you create a /home/pi/rhasspy and run rhasspy/docker-compose up ?

This is really not clear :wink:

using

If I’m correct, from what I have read here and there:

docker-compose up -> start container according to yml settings, download images if needed.
docker-compose up -d -> start container in background ??
docker-compose down -> stop and rm the container (but let volumes ??)
docker-compose down --volumes -> stop and remove everything ?

So, if a new rhasspy docker image is published, to update I would have to:

docker-compose down -v
docker-compose pull
docker-compose up

right ?

Stuff like differences between start/up and rm/down

Starting from a pi with docker, should I delete all rhasspy images/containers before installing and setting compose ?

Commands reference

:beers:

No need to docker-compose down.

Just do:

docker-compose pull && docker-compose up -d

It will only recreate the containers based on updated images.

If you manage multiple docker instances, you can take a look at Docker Swarm and maybe Portainer also.

1 Like

I won’t have multiple docker instances.

Just one Pi = one rhasspy docker

But I like to have clean stuff, so my questions about putting docker-compose.yml into a rhasspy folder.

How do you install docker-compose ? Do we have to check in the doc the last version before installing on a new device ?

Maybe it’s not a good idea to use docker compose just to start easily rhasspy ?

Don’t you have multiple Rhasspy satellites that also use docker?

I have one satellite on pi3 with docker yes. Why ?

Because using Swarm you can manage all these Docker instances from one place:

  • Deploy updated versions
  • Handle failover
  • etc

Just an idea.

Sounds good. But maybe a bit overcome for a master and satellite and maybe another test master :grin:

What I like about Swarm is the ability to deploy a service as “global” (there will be one instance of this service on each node with affinity, etc). So once you have defined your deployement, adding a new satellite is as simple as setting up docker and joining it to the swarm.

1 Like

Ok, found a simple install cmd with pip3:

sudo pip3 -v install docker-compose

So I create a docker-compose.yml

rhasspy:
    image: "rhasspy/rhasspy"
    container_name: rhasspy
    restart: unless-stopped
    volumes:
        - "$HOME/.config/rhasspy/profiles:/profiles"
        - "/etc/localtime:/etc/localtime:ro"
        - "/etc/asound.conf:/etc/asound.conf:ro"
        - "/usr/lib/arm-linux-gnueabihf/alsa-lib:/usr/lib/arm-linux-gnueabihf/alsa-lib:ro"
        - "/usr/lib/ladspa:/usr/lib/ladspa:ro"
        - type: bind
          source: $HOME/.alsaequal.bin
          target: /home/pi/.alsaequal.bin
          read_only: true
    ports:
        - "12101:12101"
    devices:
        - "/dev/snd:/dev/snd"
    command: --user-profiles /profiles --profile fr

Problem is that it works without the .alsaequal.bin file but can’t get it running with it. being -v option or type bind option.

ERROR: for rhasspy  Cannot start service rhasspy: 
OCI runtime create failed:
 container_linux.go:370: 
starting container process caused: process_linux.go:459: 
container init caused: rootfs_linux.go:59:
 mounting "/home/pi/.alsaequal.bin" to rootfs at "/var/lib/docker/overlay2/4757877b33e95e830c98d500f9704ee2e302d9714ba738bc5e5e4ddb036c2e6c/merged/home/pi/.alsaequal.bin" caused: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

Ah of course, I tested:

docker-compose down 
docker-compose build
docker-compose up -d

and it works !! :face_with_raised_eyebrow:

Seems a nice and elegant solution to set container parameters one time, indeed.

I guess docker-compose parse yml file, and under the hood it just start a docker run with all parameters ?

What’s the impact of docker compose on cpu / ram ? I guess it’s a few commands interpreter than run docker and close itself ? Nothing running in background (daemon, services) ?

Question that may sound stupid, but typing docker-compose xx a lot is … long.

Is there a way to make a shortcut, to be able for example, to just type:
dcp up -d
dcp pull
dcp restart

etc …

:smirk:

EDIT:
Seems something like this would work:
alias dcp='docker-compose "$@"'

And set it at startup in ~/.bashrc

Will try it once at home :wink:

Edit 2: Alias works perfectly :hugs: :+1:t2:

2 Likes

Hi @fastjack,
As I’ve several satellites and a bit lazy (and curious) and also got Portainer alrready installed as an HomeAssistant add-on, would it be possible to use it to manage the updated of my “mini-park/mini-infrastructure”.

If so, have you any recommendation for a tutorials/step by step guide (for noobs :nerd_face:)

Thanks !

I tested Portainer and Docker Swarm at work a few years ago. Really liked both but never really used them as we finally went the Kubernetes route.

Portainer should help you manage your docker instances but without Swarm I think they’d need to all be exposed via TCP which is not very secure…

1 Like

Hi @fastjack,
Sorry for late feedback :sleeping: I just dip a finger in DockerSwarm but I’ve burn my hand :crazy_face: so I’ll keep the CLI way.
Just maybe semi automate it thanks to some nice script that monitor a bit the PIs, then with little scripts.
I follow this reddit thread : https://www.reddit.com/r/homeassistant/comments/lxco65/my_homelab_page_on_ha_with_host_monitoring_and/?utm_medium=android_app&utm_source=share

The key is the SystemSensors by Sennevds for the MQTT monitoring stats.