Docker Dind Volume Issue
Hey team
I’m struggling to build the following setup
I have my Linux virtual machine running on Azure acting as a coder host
And I have the default docker template that you provide
I’m creating an workspace and installing docker inside of it
Inside the workspace I’m cloning my git repo that includes an docker-compose that setups my project using VOLUMES
But when I run the docker compose and I exec inside the containers, the files are actually directories, I spent some hours googling it and it seems that this is related to the docker inside my workspace actually using my host docker sock ( kind weird but I think that’s it ) and because of that docker is not able to really find the git clonned repo to be used as a volume
Do you know how fix this? Or if can I use a different approach?
I really need to use the docker-compose with volumes because because I need to use the hot reload feature to improve my experience
24 Replies
<#1120502779639762956>
Category
Help needed
Product
Coder OSS (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
I'd recommend using sysbox with Coder to allow your Docker containers to run Docker.
https://coder.com/docs/v2/latest/templates/docker-in-workspaces#use-sysbox-in-docker-based-templates
Docker in Workspaces - Coder v2 Docs
Use docker inside containerized templates
Hey @Marco Aleixo, did you managed to find a solution for your problem? I facing the same issues.
@nelsonsilva Have you explored using the sysbox-runc?
more details in the link Kyle shared above
Try and update and I will be happy to help
I was not able to put sysbox-runc working, I got it working only with a privileged sidecar container (https://coder.com/docs/v2/latest/templates/docker-in-workspaces#privileged-sidecar-container) which I understand is not optimal.
Docker in workspaces - Coder v2 Docs
Use Docker inside containerized templates
It should be two steps.
1. Install sysbox-runc
2. Update template to to use sysbox-runc as the docker runtime
It should not require a privileged container
Where should I install sysbox-runc? On the host or on the docker container which I am running coder?
I use docker-compose to set up coder, like the docs specifies (https://coder.com/docs/v2/latest/install/docker#requirements)
Docker - Coder v2 Docs
Install Coder with Docker / docker-compose
In a selfhosted server
sysbox-runc should be installed on the docker host(s) where your workspaces will be provisioned.
Sorry but I am still not sure where to install it. Now, I set coder up using the docker-compose file and I am mounting the docker socket to the container. I am not allowed to install sysbox-runc on the host machine because we have another projects that need another runtime engine.
So, do I have to install it on the docker container where I have coder or on my host machine?
It should be on host machine in this case
as you are mounting the host docker socker within the coder container
So Coder will provision all workspaces on the Host
Can I not mount the docker socket volume and then install sysbox on the container?
Installing sysbox-runc adds sysboc-runc as an additional option for the runtime
and other projects can still use other runtimes
Ahh ok, I see
Thanks, then I try it out
But make sure you follow the intsrcutions for installing sysbox correctly
I need to schedule it for the right time since I have to stop every container
So I can't make that during a work day
they recommend stopping and removing all running containers before installation
Yes
Or better set up a different docker host for Coder workspaces
and use the ssh connection in your template to conect to the remote host
In that case, you do not need to use the docker socket of the host machine at all.
How can I do that?
That you be much better
If I didn't need the docker socket of the host machine
You need another host another machine and install docker there with sysbox
Unfortunately I will not be able to do that.
I will try installing sysbox on my host and see if I can work from that on
And then you can just mount the ssh key to your coder container and modify the template to use the remote docker host over ssh
helllo @Atif, after installing sysbox on my host server, I'm having problems get it working on my docker in docker workspace.
After following the docs I did not manage to put it working.
Are the docs updated?
I will put here how all my setup is configured, maybe it will help you better understand my problem.
Coder is running using the docker-compose file based on coder docs (https://github.com/coder/coder/blob/main/docker-compose.yaml). I updated some values, but that is basically it.
I create a new template using a started docker containers template.
I edited the Dockerfile to use a custom one.
I edited the main.tf file and include what is on coder sysbox docs (https://coder.com/docs/v2/latest/templates/docker-in-workspaces#use-sysbox-in-docker-based-templates).
What I have for now is this:
and
If I start the workspace, I am not able to run a simple docker run hello-world. I'm new to terraform and sorry if anything that I say or/and aks sounds stupid.
Also got a warning saying
Workspace is unhealthy - Your workspace is running but 1 agent is unhealthy.
I don't want to use docker with sudo command behind.hey @nelsonsilva, your config looks good, did you have any luck?