We are using a bridge network in our docker-compose file, like this
services:
mqtt_broker-mosquitto:
image: eclipse-mosquitto
networks:
- mosquitto
hostname: broker0
ports:
- 1883:1883
volumes:
- ./conf:/mosquitto/config
- ./data:/mosquitto/data
- ./log:/mosquitto/log
restart: always
app1:
depends_on:
- mqtt_broker-mosquitto
networks:
- mosquitto
image: app1
restart: always
networks:
mosquitto:
name: mosquitto
driver: bridge
When an update to the docker-compose is pushed, aktualizr tries to bring down the services using docker-compose down. The network says it still has active endpoints, even though our containers are stopped and removed before docker-compose tries to remove the network.
root@verdin-imx8mm-06944039:~# journalctl -u aktualizr-torizon -f
Nov 08 16:30:28 verdin-imx8mm-06944039 aktualizr-torizon[1598]: Updating containers via docker-compose
Nov 08 16:30:28 verdin-imx8mm-06944039 aktualizr-torizon[1598]: Running docker-compose down
Nov 08 16:30:28 verdin-imx8mm-06944039 aktualizr-torizon[1598]: Running command: /usr/bin/docker-compose --file /var/sota/storage/docker-compose/docker-compose.yml -p torizon down
...
Nov 08 16:30:28 verdin-imx8mm-06944039 aktualizr-torizon[4153]: Network mosquitto Removing
Nov 08 16:30:28 verdin-imx8mm-06944039 aktualizr-torizon[4153]: Network mosquitto Error
Nov 08 16:30:28 verdin-imx8mm-06944039 aktualizr-torizon[4153]: failed to remove network mosquitto: Error response from daemon: error while removing network: network mosquitto id 2eb853cad10eacd9e4c91eb3ec75dec044dd6d5ccbbb9685c7e4f90aa8a5b088 has active endpoints
Nov 08 16:30:28 verdin-imx8mm-06944039 aktualizr-torizon[1598]: docker-compose down of old image failed
Nov 08 16:30:28 verdin-imx8mm-06944039 aktualizr-torizon[1598]: Event: InstallTargetComplete, Result - Error
Nov 08 16:30:28 verdin-imx8mm-06944039 aktualizr-torizon[1598]: Event: AllInstallsComplete, Result - docker-compose:INSTALL_FAILED
The only way to use docker-compose down (even manually) with this bridge network is to use a workaround, such as this
docker kill $(docker ps -q)
We have a couple of ideas, but I was hoping you could suggest something better.
- It might work to patch aktualizr (modifying this line https://github.com/toradex/aktualizr-torizon/blob/302805c724e8e36010008f02e09e8d9108830b96/src/aktualizr_torizon_primary/compose_manager.cc#L31). This would require either doing a yocto build (I really don’t want to do a yocto build), or using the torizoncore builder to package a custom build of aktualizr (also seems less than ideal).
- We’ve also considered running a script that will check if an update is pending, then running our manual workaround command before / while aktualizr does its work. This seems a bit hacky and not entirely reliable.
Is there a different way we should be configuring the bridge network so that docker-compose down will work as normal? Or some kind of settings in aktualizr that can be changed to accomodate this?