Skip to content

Instantly share code, notes, and snippets.

@altbdoor
Last active July 6, 2024 09:08
Show Gist options
  • Save altbdoor/e6e97b96f498ac8773a7409a70c8795d to your computer and use it in GitHub Desktop.
Save altbdoor/e6e97b96f498ac8773a7409a70c8795d to your computer and use it in GitHub Desktop.
Running Alpine with WSL2 and Docker

Running Alpine with WSL2 and Docker

Prepare Windows

  1. Turn Windows features on or off
  2. Enable:
    1. Windows Subsystem for Linux (WSL)
    2. Virtual Machine Platform
  3. wsl --update

Installing Alpine

Updating Alpine

# update all packages
apk update
apk upgrade

# update version if required
sed -i -e 's/3.15/3.16/g' /etc/apk/repositories
sed -i -e 's/3.15/latest-stable/g' /etc/apk/repositories
apk update
apk upgrade --available && sync

# then reboot

Docker

# warning, docker-compose is v1
#          docker-compose-cli is v2
apk add docker docker-cli-compose

# custom profile
cat <<EOF > /etc/profile.d/profile.sh
alias ls="ls -Ah --color=auto"
alias ll="ls -l"
alias goproject="cd /mnt/c/Users/carbon/projects"
if [ ! -e /var/run/docker.sock ]; then
    echo "(i) Docker is running"
    dockerd &> /tmp/dockerd.log &
else
    echo "(i) Docker is already running"
fi

export DOCKER_USER="$(id -u):$(id -g)"
goproject
EOF

source /etc/profile.d/profile.sh

Podman

WIP... Podman not really 1:1 to Docker

# podman alternative
apk add podman
ln -s $(which podman) /usr/local/bin/docker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment