Coder.comC
Coder.com16mo ago
34 replies
anubis

Docker in Docker with sysbox cant find the deamon

Hello,

I have installed coder with docker-compose. Also installed sysbox on the host that coder runs. I am trying to get docker to work inside the docker container but i get cannot connect to the docker daemon at unix:///var/run/docker.sock. is the docker daemon running?

My dockerfile is the following:
FROM ubuntu

RUN apt-get update \
    && apt-get install -y \
    curl \
    ca-certificates \
    git \
    golang \
    sudo \
    vim \
    wget \
    # Install Python
    python3 \
    python3-pip \
    python3-venv \
    python3-dev \
    && rm -rf /var/lib/apt/lists/*

# Install nodejs and MegaLinter globally
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - \
    && sudo apt-get install -y nodejs \
    && sudo npm install mega-linter-runner -g

# Add Docker's official GPG key:
RUN sudo install -m 0755 -d /etc/apt/keyrings \
    && sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc \
    && sudo chmod a+r /etc/apt/keyrings/docker.asc \ 
    && echo \
    "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
    $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
    sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

# Docker install
RUN sudo apt-get update \
    && sudo apt-get install -y \ 
    docker-ce \
    docker-ce-cli \
    containerd.io \
    docker-buildx-plugin \
    docker-compose-plugin

# Fix locale
RUN sudo apt-get update \
    && apt-get install -y locales \
    && sudo locale-gen en_US.UTF-8 \
    && sudo update-locale LANG=en_US.UTF-8

ARG USER=coder
RUN useradd --groups sudo --no-create-home --shell /bin/bash ${USER} \
    && echo "${USER} ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/${USER} \
    && chmod 0440 /etc/sudoers.d/${USER}
USER ${USER}
WORKDIR /home/${USER}

# Add user to docker group
RUN sudo usermod -aG docker $USER \
    && newgrp docker


Attached is the main.tf
Was this page helpful?