Skip to content

Commit badd326

Browse files
committed
Run Docker without Docker Desktop
This will only be run on WSL 2 and if you don't want to install and run Docker this way then the service won't exist in which case nothing will get started or output.
1 parent 7f63527 commit badd326

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

.config/zsh/.zprofile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,15 @@ export LESS_TERMCAP_so=$'\e[1;44;33m' # begin standout-mode - info box
2323
export LESS_TERMCAP_me=$'\e[0m' # end mode
2424
export LESS_TERMCAP_ue=$'\e[0m' # end underline
2525
export LESS_TERMCAP_se=$'\e[0m' # end standout-mode
26+
27+
# Ensure Docker is running on WSL 2. This expects you've installed Docker and
28+
# Docker Compose directly within your WSL distro instead of Docker Desktop, such as:
29+
# - https://docs.docker.com/engine/install/ubuntu/#install-using-the-convenience-script
30+
# - https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user
31+
# - https://docs.docker.com/compose/install/linux/
32+
if grep -q "microsoft" /proc/version > /dev/null 2>&1; then
33+
if service docker status 2>&1 | grep -q "is not running"; then
34+
wsl.exe --distribution "${WSL_DISTRO_NAME}" --user root \
35+
--exec /usr/sbin/service docker start > /dev/null 2>&1
36+
fi
37+
fi

0 commit comments

Comments
 (0)