From 264daf14176f75bebbd44573d6f0875917cdba08 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Sat, 5 Nov 2022 17:26:41 +0100 Subject: [PATCH] fix: do not allow grabbing other project's container when using =ensure_db_docker_running= --- bin/compose-core | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/compose-core b/bin/compose-core index 7558b22..9a7eabf 100755 --- a/bin/compose-core +++ b/bin/compose-core @@ -722,7 +722,7 @@ export -f set_db_params export _PID="$$" ensure_db_docker_running () { - local _STATE_FILE errlvl + local _STATE_FILE errlvl project _DB_NAME="db_${DB_NAME}_${_PID}" _STATE_FILE="$state_tmpdir/${_DB_NAME}.state" @@ -761,6 +761,11 @@ ensure_db_docker_running () { --format "{{range .Mounts}}{{if eq .Destination \"$DB_DATADIR\"}}{{.Source}}{{end}}{{end}}" \ "$docker_id") if [ "$has_volume_mounted" == "$host_db_working_dir" ]; then + info "docker '$docker_id' uses '$has_volume_mounted'." + project=$(docker inspect "$docker_id" \ + --format "{{index .Config.Labels \"compose.project\" }}") || continue + info "docker '$docker_id' is from project '$project' (current project is '$PROJECT_NAME')." + [ "$project" == "$PROJECT_NAME" ] || continue found="$docker_id" break fi