Skip to content

Add docker-in-docker instructions for k8s #941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions doc/self-hosted/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,71 @@ Options:

### Help
Use `code-server --help` to view the usage for the CLI. This is also shown at the beginning of this section.

## Docker in Docker

### Kubernetes Example

This is a Kubernetes deployment for `code-server` that can run `docker` containers. It uses the official `dind` ([docker-in-docker](https://hub.docker.com/_/docker)) image and copies the `docker` binary to the `code-server` container on startup (in `/usr/local/bin`, which is empty by default).

```
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: code-server
namespace: default
spec:
replicas: 1
template:
metadata:
labels:
app: code-server
spec:
initContainers:
- name: copy-docker-binary
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you do this in a Dockerfile instead? It should lessen the need to allocate additional resources for such a task that a image build would be more fit to.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with using a Dockerfile is that we have to push and maintain the image @sr229.

I suppose its not a big deal though to include the docker CLI by default in codercom/code-server.

image: docker:stable-dind
command: ['sh', '-c', 'cp /usr/local/bin/docker /code-server-bin/']
volumeMounts:
- name: code-server-usr-local-bin
mountPath: /code-server-bin
containers:
- name: code-server
image: linuxserver/code-server
imagePullPolicy: Always
ports:
- containerPort: 8443
name: https
envFrom:
- configMapRef:
name: code-server
- secretRef:
name: code-server
volumeMounts:
- name: config
mountPath: /config
readOnly: false
- name: code-server-usr-local-bin
mountPath: /usr/local/bin
- name: dind-daemon
image: docker:stable-dind
env:
- name: DOCKER_TLS_CERTDIR
value: ""
resources:
requests:
cpu: 20m
memory: 512Mi
securityContext:
privileged: true
volumeMounts:
- name: docker-graph-storage
mountPath: /var/lib/docker
volumes:
- name: config
persistentVolumeClaim:
claimName: code-server-config
- name: docker-graph-storage
emptyDir: {}
- name: code-server-usr-local-bin
emptyDir: {}
```