diff --git a/registry/coder-labs/templates/docker-build/README.md b/registry/coder-labs/templates/docker-build/README.md index 94d01b88..9ed62f68 100644 --- a/registry/coder-labs/templates/docker-build/README.md +++ b/registry/coder-labs/templates/docker-build/README.md @@ -8,6 +8,10 @@ tags: [docker, container, dockerfile] # Remote Development on Docker Containers (Build from Dockerfile) +> [!NOTE] +> This template is designed to be a starting point for testing purposes. +> In a production environment, you would want to move away from storing the Dockerfile in-template and move towards using a centralized image registry. + Build and provision Docker containers from a Dockerfile as [Coder workspaces](https://coder.com/docs/workspaces) with this example template. This template builds a custom Docker image from the included Dockerfile, allowing you to customize the development environment by modifying the Dockerfile rather than using a pre-built image. @@ -18,7 +22,22 @@ This template builds a custom Docker image from the included Dockerfile, allowin ### Infrastructure -The VM you run Coder on must have a running Docker socket and the `coder` user must be added to the Docker group: +#### Running Coder inside Docker + +If you installed Coder as a container within Docker, you will have to do the following things: + +- Make the the Docker socket available to the container + - **(recommended) Mount `/var/run/docker.sock` via `--mount`/`volume`** + - _(advanced) Restrict the Docker socket via https://github.com/Tecnativa/docker-socket-proxy_ +- Set `--group-add`/`group_add` to the GID of the Docker group on the **host** machine + - You can get the GID by running `getent group docker` on the **host** machine + +If you are using `docker-compose`, here is an example on how to do those things (don't forget to edit `group_add`!): +https://github.com/coder/coder/blob/0bfe0d63aec83ae438bdcb77e306effd100dba3d/docker-compose.yaml#L16-L23 + +#### Running Coder outside of Docker + +If you installed Coder as a system package, the VM you run Coder on must have a running Docker socket and the `coder` user must be added to the Docker group: ```sh # Add coder user to Docker group diff --git a/registry/coder/templates/docker-devcontainer/README.md b/registry/coder/templates/docker-devcontainer/README.md index b5341071..3b2a4370 100644 --- a/registry/coder/templates/docker-devcontainer/README.md +++ b/registry/coder/templates/docker-devcontainer/README.md @@ -14,11 +14,26 @@ Provision Devcontainers as [Coder workspaces](https://coder.com/docs/workspaces) ### Infrastructure -Coder must have access to a running Docker socket, and the `coder` user must be a member of the `docker` group: +#### Running Coder inside Docker -```shell +If you installed Coder as a container within Docker, you will have to do the following things: + +- Make the the Docker socket available to the container + - **(recommended) Mount `/var/run/docker.sock` via `--mount`/`volume`** + - _(advanced) Restrict the Docker socket via https://github.com/Tecnativa/docker-socket-proxy_ +- Set `--group-add`/`group_add` to the GID of the Docker group on the **host** machine + - You can get the GID by running `getent group docker` on the **host** machine + +If you are using `docker-compose`, here is an example on how to do those things (don't forget to edit `group_add`!): +https://github.com/coder/coder/blob/0bfe0d63aec83ae438bdcb77e306effd100dba3d/docker-compose.yaml#L16-L23 + +#### Running Coder outside of Docker + +If you installed Coder as a system package, the VM you run Coder on must have a running Docker socket and the `coder` user must be added to the Docker group: + +```sh # Add coder user to Docker group -sudo usermod -aG docker coder +sudo adduser coder docker # Restart Coder server sudo systemctl restart coder diff --git a/registry/coder/templates/docker/README.md b/registry/coder/templates/docker/README.md index a65c45f8..2b5885bb 100644 --- a/registry/coder/templates/docker/README.md +++ b/registry/coder/templates/docker/README.md @@ -16,7 +16,22 @@ Provision Docker containers as [Coder workspaces](https://coder.com/docs/workspa ### Infrastructure -The VM you run Coder on must have a running Docker socket and the `coder` user must be added to the Docker group: +#### Running Coder inside Docker + +If you installed Coder as a container within Docker, you will have to do the following things: + +- Make the the Docker socket available to the container + - **(recommended) Mount `/var/run/docker.sock` via `--mount`/`volume`** + - _(advanced) Restrict the Docker socket via https://github.com/Tecnativa/docker-socket-proxy_ +- Set `--group-add`/`group_add` to the GID of the Docker group on the **host** machine + - You can get the GID by running `getent group docker` on the **host** machine + +If you are using `docker-compose`, here is an example on how to do those things (don't forget to edit `group_add`!): +https://github.com/coder/coder/blob/0bfe0d63aec83ae438bdcb77e306effd100dba3d/docker-compose.yaml#L16-L23 + +#### Running Coder outside of Docker + +If you installed Coder as a system package, the VM you run Coder on must have a running Docker socket and the `coder` user must be added to the Docker group: ```sh # Add coder user to Docker group