energy-quants / bootstrap

A repo containing scripts for bootstrapping a development environment
MIT License
0 stars 1 forks source link

`[docker]` Should we start the daemon as part of the install? #20

Open dhirschfeld opened 2 years ago

dhirschfeld commented 2 years ago

Probably?

Currently, testing the version blows up:

+ docker version
Client: Docker Engine - Community
 Version:           20.10.17
 API version:       1.41
 Go version:        go1.17.11
 Git commit:        100c701
 Built:             Mon Jun  6 23:02:46 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
dhirschfeld commented 2 years ago

https://dev.to/bowmanjd/install-docker-on-windows-wsl-without-docker-desktop-34m9

dhirschfeld commented 2 years ago
sudo usermod -aG docker $USER

Need to do magic to find correct $USER

dhirschfeld commented 2 years ago
DOCKER_DIR=/mnt/wsl/shared-docker
mkdir -pm o=,ug=rwx "$DOCKER_DIR"
chgrp docker "$DOCKER_DIR"
sudo mkdir /etc/docker/
sudo tee /etc/docker/daemon.json << EOF
{
  "hosts": ["unix:///mnt/wsl/shared-docker/docker.sock"]
}
EOF

Necessary startup script:

❯ cat /etc/profile.d/07-docker-daemon.sh
DOCKER_DISTRO="Ubuntu-22.04"
DOCKER_DIR=/mnt/wsl/shared-docker
DOCKER_SOCK="$DOCKER_DIR/docker.sock"
export DOCKER_HOST="unix://$DOCKER_SOCK"
if [ ! -S "$DOCKER_SOCK" ]; then
    mkdir -pm o=,ug=rwx "$DOCKER_DIR"
    chgrp docker "$DOCKER_DIR"
    /mnt/c/Windows/System32/wsl.exe -u root -d $DOCKER_DISTRO sh -c "nohup sudo -b dockerd < /dev/null > $DOCKER_DIR/dockerd.log 2>&1"
fi

Necessary env-var:

export DOCKER_HOST="unix:///mnt/wsl/shared-docker/docker.sock"