-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
install docker in wsl without docker desktop
- Loading branch information
Showing
7 changed files
with
344 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
isWSL=$(uname -a | grep WSL | wc -l) | ||
|
||
if [ $isWSL -eq 1 ]; then | ||
|
||
# if /bin/docker-service | ||
if [ -f $HOME/bin/docker-service.sh ]; then | ||
. $HOME/bin/docker-service.sh "Ubuntu-22.04" | ||
fi | ||
|
||
# check if docker is completely installed inside WSL without dockerd desktop | ||
DOCKER_SOCK="/mnt/wsl/shared-docker/docker.sock" | ||
test -S "$DOCKER_SOCK" && export DOCKER_HOST="unix://$DOCKER_SOCK" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# # https://dev.to/bowmanjd/using-podman-on-windows-subsystem-for-linux-wsl-58ji | ||
# set -x | ||
# if [[ -x "$(command -v podman)" ]]; then | ||
# # Define runtime dir for podman socket | ||
# if [[ -z "$XDG_RUNTIME_DIR" ]]; then | ||
# export XDG_RUNTIME_DIR=/run/user/$UID | ||
# if [[ ! -d "$XDG_RUNTIME_DIR" ]]; then | ||
# export XDG_RUNTIME_DIR=/tmp/$USER-runtime | ||
# if [[ ! -d "$XDG_RUNTIME_DIR" ]]; then | ||
# mkdir -m 0700 "$XDG_RUNTIME_DIR" | ||
# fi | ||
# fi | ||
# fi | ||
# # Check if podman service is running (rootless), and start if not. | ||
# if ! pgrep -f -x 'podman system service -t 0' > /dev/null;then | ||
# podman system service -t 0 > /dev/null 2>&1 & | ||
# fi | ||
# # Define DOCKER_HOST to podman socket, so docker-compose can work with it | ||
# # I've installed docker-compose using: pip3 install docker-compose from my user (non-root) | ||
# DOCKER_HOST=`echo "unix://${XDG_RUNTIME_DIR}/podman/podman.sock"` | ||
# export DOCKER_HOST | ||
# fi | ||
# set +x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# bin | ||
|
||
This folder contains binary files or scripts. | ||
|
||
## Files | ||
|
||
| File | Description | url | | ||
| ---- | ----------- | --- | | ||
| docker-service.sh | Docker service to start docker when | <https://github.com/bowmanjd/docker-wsl/blob/main/docker-service.sh> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/sh | ||
# Launcher for dockerd on WSL 2 | ||
|
||
# Copyright 2021 Jonathan Bowman. All documentation and code contained | ||
# in this file may be freely shared in compliance with the | ||
# Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) | ||
# and is provided "AS IS" without warranties or conditions of any kind. | ||
# | ||
# To use this script, first ask yourself if I can be trusted, then read the code | ||
# below and make sure you feel good about it, then consider downloading and | ||
# executing this code that comes with no warranties or claims of suitability. | ||
# | ||
# You might name this script "docker-service" and place it in "$HOME/bin". | ||
# | ||
# This script should be called with a single argument: the name of the WSL | ||
# distribution with dockerd. To find a list of WSL distros, launch Powershell then | ||
# | ||
# wsl -l -q | ||
# | ||
# A usage example: | ||
# | ||
# $HOME/bin/docker-service Ubuntu | ||
# | ||
# If no distribution is specified, the default one will be used. | ||
# This script can also be sourced from your shell initialization script, such | ||
# as .bashrc or .profile, with something like (assuming distro is "Ubuntu": | ||
# | ||
# . $HOME/bin/docker-service Ubuntu | ||
# | ||
# Or called from Windows with | ||
# | ||
# wsl -d Ubuntu ~/bin/docker-service Ubuntu | ||
|
||
[ -z "$1" ] && DOCKER_DISTRO="$WSL_DISTRO_NAME" || DOCKER_DISTRO="$1" | ||
# If embedding this in .bashrc, .profile, .zshenv, or the like, remove the above line | ||
# and set $DOCKER_DISTRO to an empty string or something like this: | ||
# DOCKER_DISTRO="Ubuntu" | ||
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 -d $DOCKER_DISTRO sh -c "nohup sudo -b dockerd < /dev/null > $DOCKER_DIR/dockerd.log 2>&1" | ||
fi |
Oops, something went wrong.