19 lines
600 B
Bash
19 lines
600 B
Bash
#!/bin/sh
|
|
# Explicit Compose labels scope the socket to this local test project.
|
|
case "${LAB4_PROJECT:-}" in
|
|
mtusi-lab4-grade3|mtusi-lab4-grade3-*) ;;
|
|
*) echo 'LAB4_PROJECT must identify the Lab 4 test stack' >&2; exit 2 ;;
|
|
esac
|
|
|
|
container() {
|
|
ids=$(docker ps -aq --filter "label=com.docker.compose.project=$LAB4_PROJECT" \
|
|
--filter "label=com.docker.compose.service=$1" \
|
|
--filter 'label=com.docker.compose.oneoff=False')
|
|
set -- $ids
|
|
if [ "$#" -ne 1 ]; then
|
|
echo 'Expected one Lab 4 service container' >&2
|
|
return 2
|
|
fi
|
|
printf '%s\n' "$1"
|
|
}
|