Docker: Where did I start that container?

Introduction

Sometimes I am not as structured as I would like to be, and I tend to forget things. So, when I log onto a VM where I have a handful of docker containers running, it is not always clear where I started them from.

I usually try and follow a naming convention, and hopefully I have put my docker compose configurations under /var/lib/ops/APPLICATION_NAME, but that is not always the case.

My contribution, so that you won’t find yourself in the same situation: Here is a simple one-liner to help you find your docker-compose.yml files:

maglub@wue-docker-l02:~$ docker ps | awk '{print $1}' | grep -v CONTAINER | xargs -IX docker inspect X | jq -r '[.[0].Name[1:], .[0].Config.Labels["com.docker.compose.project.working_dir"]] | @csv' | sed -e 's/,/: /' -e 's/"//g'
immich_server: /home/ops/docker/immich
immich-pgadmin-1: /home/ops/docker/immich
immich_postgres: /home/ops/docker/immich
immich_machine_learning: /home/ops/docker/immich
immich_redis: /home/ops/docker/immich
ocr-ocr-1: /home/ops/docker/ocr
jellyfin: /home/ops/docker/jellyfin
prometheus-prometheus-1: /home/ops/docker/prometheus
admin-gui-web-1: /home/ops/docker/admin-gui
admin-gui-admin-gui-1: /home/ops/docker/admin-gui
paperless-webserver-1: /home/ops/docker/paperless
paperless-db-1: /home/ops/docker/paperless
paperless-broker-1: /home/ops/docker/paperless
unifi-controller: /home/ops/docker/unifi
icinga2-icingadb-1: /home/ops/docker/icinga2
icinga2-icingaweb-1: /home/ops/docker/icinga2
icinga2-icinga2-1: /home/ops/docker/icinga2
icinga2-director-1: /home/ops/docker/icinga2
icinga2-influxdb-1: /home/ops/docker/icinga2
icinga2-icingadb-redis-1: /home/ops/docker/icinga2
icinga2-mysql-1: /home/ops/docker/icinga2
samba4ad-samba4ad-1: /home/ops/docker/samba4ad
grafana-renderer-1: /home/ops/docker/grafana
grafana-grafana-1: /home/ops/docker/grafana

Enjoy!