-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecutable_syd
More file actions
62 lines (49 loc) · 1.28 KB
/
executable_syd
File metadata and controls
62 lines (49 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bash
set -euo pipefail
CONTAINER_FLAGS=(
--detach=true
--tty=true
--entrypoint=/usr/lib/systemd/systemd
--env=container="docker"
--stop-signal=SIGRTMIN+3
--cgroupns=private
--security-opt=writable-cgroups=true
--tmpfs=/run
--tmpfs=/run/lock
--tmpfs=/tmp
)
HAS_ARGS=0
usage() {
cat << EOF
Usage: syd [OPTIONS] IMAGE
Launch a system container with Docker using systemd-compatible configuration.
Arguments:
IMAGE Docker image to run (must always be in last position).
Options:
-h, --help Display this help message
-n, --name NAME Set container hostname
Any other Docker run options can be passed as-is and will be added to the configuration.
Examples:
# Launch a container with the default configuration:
syd ghcr.io/f-bn/ubuntu:24.04-init
# Launch a container with custom configurations:
syd --name c1 --net=my-network ghcr.io/f-bn/ubuntu:24.04-init
EOF
}
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
usage ; exit 0 ;;
-n|--name)
CONTAINER_FLAGS+=(--name="$2" --hostname="$2");
shift 2 ;;
*)
CONTAINER_FLAGS+=("$1"); HAS_ARGS=1;
shift ;;
esac
done
if [[ $HAS_ARGS -eq 0 ]]; then
usage ; exit 0
fi
echo "Launching systemd container with Docker"
exec docker run "${CONTAINER_FLAGS[@]}"