Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d5e2454

Browse files
bpmctkylecarbs
andauthored
chore: rework docker in docker docs (#5876)
* chore: rework docker in docker docs * Update docs/templates/docker-in-docker.md Co-authored-by: Kyle Carberry <[email protected]> * fix typos --------- Co-authored-by: Kyle Carberry <[email protected]>
1 parent 52ace4b commit d5e2454

File tree

2 files changed

+12
-46
lines changed

2 files changed

+12
-46
lines changed

.github/workflows/typos.toml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ MacOS = "macOS"
66
AKS = "AKS"
77

88
[default.extend-words]
9+
AKS = "AKS"
910
# do as sudo replacement
1011
doas = "doas"
1112
darcula = "darcula"

docs/templates/docker-in-docker.md

+11-46
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
# Docker in Docker
2+
13
There are a few ways to run Docker within container-based Coder workspaces.
24

3-
## Sysbox runtime (recommended)
5+
| Method | Description | Limitations |
6+
| ---------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
7+
| [Sysbox container runtime](#sysbox-container-runtime) | Install sysbox on your Kubernetes nodes for secure docker-in-docker and systemd-in-docker. Works with GKE, EKS, AKS. | Requires [compatible nodes](https://github.com/nestybox/sysbox#host-requirements). Max of 16 sysbox pods per node. [See all](https://github.com/nestybox/sysbox/blob/master/docs/user-guide/limitations.md) |
8+
| [Privileged docker sidecar](#privileged-sidecar-container) | Run docker as a privilged sidecar container. | Requires a privileged container. Workspaces can break out to root on the host machine. |
49

5-
The [Sysbox](https://github.com/nestybox/sysbox) container runtime allows unprivileged users to run system-level applications, such as Docker, securely from the workspace containers. Sysbox requires a [compatible Linux distribution](https://github.com/nestybox/sysbox/blob/master/docs/distro-compat.md) to implement these security features.
10+
## Sysbox container runtime
611

7-
> Sysbox can also be used to run systemd inside Coder workspaces. See [Systemd in Docker](#systemd-in-docker).
12+
The [Sysbox](https://github.com/nestybox/sysbox) container runtime allows unprivileged users to run system-level applications, such as Docker, securely from the workspace containers. Sysbox requires a [compatible Linux distribution](https://github.com/nestybox/sysbox/blob/master/docs/distro-compat.md) to implement these security features. Sysbox can also be used to run systemd inside Coder workspaces. See [Systemd in Docker](#systemd-in-docker).
813

914
### Use Sysbox in Docker-based templates
1015

@@ -106,7 +111,9 @@ resource "kubernetes_pod" "dev" {
106111
107112
## Privileged sidecar container
108113

109-
While less secure, you can attach a [privileged container](https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities) to your templates. This may come in handy if your nodes cannot run Sysbox.
114+
A [privileged container](https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities) can be added to your templates to add docker support. This may come in handy if your nodes cannot run Sysbox.
115+
116+
> ⚠️ **Warning**: This is insecure. Workspaces will be able to gain root access to the host machine.
110117
111118
### Use a privileged sidecar container in Docker-based templates
112119

@@ -212,48 +219,6 @@ resource "kubernetes_pod" "main" {
212219

213220
Additionally, [Sysbox](https://github.com/nestybox/sysbox) can be used to give workspaces full `systemd` capabilities.
214221

215-
### Use systemd in Docker-based templates
216-
217-
After [installing Sysbox](https://github.com/nestybox/sysbox#installation) on the Coder host, modify your template to use the sysbox-runc runtime and start systemd:
218-
219-
```hcl
220-
resource "docker_container" "workspace" {
221-
image = "codercom/enterprise-base:ubuntu"
222-
name = "coder-${data.coder_workspace.me.owner}-${lower(data.coder_workspace.me.name)}"
223-
224-
# Use Sysbox container runtime (required)
225-
runtime = "sysbox-runc"
226-
# Run as root in order to start systemd (required)
227-
user = "0:0"
228-
229-
# Start systemd and the Coder agent
230-
command = ["sh", "-c", <<EOF
231-
# Start the Coder agent as the "coder" user
232-
# once systemd has started up
233-
sudo -u coder --preserve-env=CODER_AGENT_TOKEN /bin/bash -- <<-' EOT' &
234-
while [[ ! $(systemctl is-system-running) =~ ^(running|degraded) ]]
235-
do
236-
echo "Waiting for system to start... $(systemctl is-system-running)"
237-
sleep 2
238-
done
239-
${coder_agent.main.init_script}
240-
EOT
241-
242-
exec /sbin/init
243-
EOF
244-
,
245-
]
246-
env = ["CODER_AGENT_TOKEN=${coder_agent.main.token}"]
247-
}
248-
249-
resource "coder_agent" "main" {
250-
arch = data.coder_provisioner.me.arch
251-
os = "linux"
252-
}
253-
```
254-
255-
### Use systemd in Kubernetes-based templates
256-
257222
After [installing Sysbox on Kubernetes](https://github.com/nestybox/sysbox/blob/master/docs/user-guide/install-k8s.md),
258223
modify your template to use the sysbox-runc RuntimeClass. This requires the Kubernetes Terraform provider version 2.16.0 or greater.
259224

0 commit comments

Comments
 (0)