Browse Source

fix: do not allow grabbing other project's container when using =ensure_db_docker_running=

cache-relation
Valentin Lab 2 years ago
parent
commit
264daf1417
  1. 7
      bin/compose-core

7
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

Loading…
Cancel
Save