-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecutable_syd
More file actions
57 lines (46 loc) · 1.11 KB
/
executable_syd
File metadata and controls
57 lines (46 loc) · 1.11 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
#!/usr/bin/env bash
set -euo pipefail
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:
Any Docker run options can be passed and will be added to the default configuration.
Examples:
syd ghcr.io/f-bn/ubuntu:24.04-init
syd --name my-container --net=my-network ghcr.io/f-bn/ubuntu:24.04-init
EOF
}
FLAGS=(
--tty=true
--entrypoint=/sbin/init
--env=container="docker"
--stop-signal=SIGRTMIN+3
--cgroupns=host
--cgroup-parent=machine.slice
--volume=/sys/fs/cgroup:/sys/fs/cgroup:rw
--tmpfs=/run
--tmpfs=/run/lock
--tmpfs=/tmp
)
HAS_ARGS=0
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
usage ; exit 0 ;;
--name)
FLAGS+=(--name="$2" --hostname="$2");
shift 2 ;;
*)
FLAGS+=("$1"); HAS_ARGS=1;
shift ;;
esac
done
if [[ $HAS_ARGS -eq 0 ]]; then
usage ; exit 0
fi
echo "Launching systemd container with Docker"
CONTAINER=$(docker create "${FLAGS[@]}") || exit 1
exec docker start "${CONTAINER}"