mirror of
https://github.com/p8952/bocker.git
synced 2025-11-08 19:54:01 +01:00
24 lines
747 B
Bash
24 lines
747 B
Bash
#!/usr/bin/env bash
|
|
set -o errexit -o nounset -o pipefail
|
|
|
|
img="$(./bocker init ~/base-image | awk '{print $2}')"
|
|
./bocker images | grep -qw "$img"
|
|
[[ "$?" == 0 ]]
|
|
|
|
# ▼ ▼ ▼ Race condition waiting to happen ▼ ▼ ▼
|
|
./bocker run "$img" "sleep 5 && ps aux" &
|
|
sleep 2
|
|
ps="$(./bocker ps | grep 'sleep 5' | awk '{print $1}')"
|
|
exec="$(./bocker exec "$ps" ps aux | wc -l)"
|
|
[[ "$exec" == "4" ]]
|
|
sleep 3
|
|
# ▲ ▲ ▲ Race condition waiting to happen ▲ ▲ ▲
|
|
|
|
./bocker run "$img" ps aux
|
|
ps="$(./bocker ps | grep 'ps aux' | awk '{print $1}')"
|
|
exec="$(./bocker exec "$ps" ps aux)" || true
|
|
[[ "$exec" == "Container '$ps' exists but is not running" ]]
|
|
|
|
exec="$(./bocker exec foo ps aux)" || true
|
|
[[ "$exec" == "No container named 'foo' exists" ]]
|