Use docker in workspace
I used curl -L https://coder.com/install.sh | sh to deploy Coder and installed Sysbox and Docker, but still unable to use Docker in the workspace normally. I have added Coder to the Docker user group.
These are the two different templates I tried.
- starter template Docker Containers ( I downloaded Docker in the workspace.)
- starter template Docker Containers but
image = "codercom/ubuntu-docker:latest"errordocker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
Are you certain the Coder user is in the Docker group?
You can try sudo su coder and running docker ps to see if the perms are correct.
Are you certain the Coder user is in the Docker group?
You can try
sudo su coderand runningdocker psto see if the perms are correct.
It's indeed in the Docker group.
There is a way to get workspace to use Docker which is on a host Dockerfile
RUN apt-get update \
&& apt-get install -y \
curl \
git \
golang \
sudo \
vim \
wget \
# add docker cli
docker.io \
&& rm -rf /var/lib/apt/lists/*
main.tf
resource "docker_container" "workspace" {
# add
volumes {
host_path = "/var/run/docker.sock"
container_path = "/var/run/docker.sock"
}
}
Is there a good way to use Docker in this workspace and still keep Ubuntu.
This gives the workspace full access to the host docker socket, which is unsafe. You should check this guide for a safer way to do this.