I have several use cases where an action in one docker-compose service should trigger some activity in another.
- certbot renewal in a certbot container should trigger nginx reload in a nginx container
- OSM import in an osm2pgsql container should trigger re-render in a mapnik/tilestache container
I found an easy way to do this, using netcat
For example in the nginx
docker-compose service could start a netcat in listen mode like this
nc -p 23 -lk -e /usr/sbin/nginx-reload &
Where nginx-reload
is
#!/bin/sh
/usr/sbin/nginx -s reload
Then the certbot
docker-compose service can trigger nginx reload like this
nc -z webserver 23
Of course port 23 will not be exposed outside the docker-compose containers. Any other port can be used.
I wonder if there exists a docker-compose feature that I am reinventing here? Or maybe there are easier ways to do this? Thanks!