-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver_setup.sh
More file actions
executable file
·60 lines (49 loc) · 1.83 KB
/
Copy pathserver_setup.sh
File metadata and controls
executable file
·60 lines (49 loc) · 1.83 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
#!/usr/bin/env bash
set -euo pipefail
echo "[1/8] Update OS"
sudo apt update
sudo apt -y upgrade
echo "[2/8] Install basic tools"
sudo apt install -y \
ca-certificates curl gnupg lsb-release \
git make build-essential \
unzip jq htop \
openssh-server
echo "[3/8] Enable SSH"
sudo systemctl enable --now ssh
echo "[4/8] Install Docker Engine (official repo, NOT snap)"
# Remove older distro docker packages if present
sudo apt remove -y docker docker-engine docker.io containerd runc || true
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${VERSION_CODENAME}") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
echo "[5/8] Allow current user to run docker without sudo"
sudo usermod -aG docker "$USER"
echo "[6/8] Recommended: enable BuildKit by default"
mkdir -p ~/.config/docker
cat > ~/.config/docker/config.json <<'JSON'
{
"features": { "buildkit": true }
}
JSON
echo "[7/8] (Optional) Kernel tweaks for container workloads (safe defaults)"
# These are conservative; you can skip if you prefer.
sudo tee /etc/sysctl.d/99-docker-tuning.conf >/dev/null <<'CONF'
fs.inotify.max_user_watches=524288
fs.inotify.max_user_instances=1024
CONF
sudo sysctl --system >/dev/null || true
echo "[8/8] Done."
echo
echo "IMPORTANT:"
echo "- You must log out/in (or reboot) for docker group membership to take effect."
echo "- Then test: docker run hello-world"
echo
echo "Your VM IP can be checked with: hostname -I"