Skip to content

Instantly share code, notes, and snippets.

@SARDONYX-sard
Created November 3, 2022 09:17
Show Gist options
  • Save SARDONYX-sard/c1c0f1e1f2da87d284c1f05d6a142960 to your computer and use it in GitHub Desktop.
Save SARDONYX-sard/c1c0f1e1f2da87d284c1f05d6a142960 to your computer and use it in GitHub Desktop.
# This command runs on the host side of the window
#
# Deps
# - WSL Kali-linux
# - Docker
# - PowerShell Core
# - Windows11
write-output "FROM alpine:3.16.2 `nENV DISPLAY=:0 `nRUN set -eux && apk update && apk add --no-cache xeyes `nCMD [`"xeyes`"]" | out-file "./docker-xeyes" -encoding utf8 &&
docker run --rm -it -v \\wsl.localhost\kali-linux\tmp\.X11-unix:/tmp/.X11-unix "$(docker build -f ./docker-xeyes -q .)" &&
Remove-Item ./docker-xeyes
# This command is executed in a shell within a WSL.
#
# Deps
# - WSL Kali-linux
# - Docker
# - Windows11
export DOCKER_CONTENT_TRUST=0 && \
docker pull alpine:3.16.2 && \
printf 'FROM alpine:3.16.2 \nRUN set -eux && apk update && apk add --no-cache xeyes \nCMD ["xeyes"]' > ./docker-xeyes && \
docker run --rm -it -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY "$(docker build -f ./docker-xeyes -q .)" && \
/bin/rm ./docker-xeyes
@SARDONYX-sard
Copy link
Author

Result

On windows

docker-gui

On WSL

docker-gui-wsl

@SARDONYX-sard
Copy link
Author

Note:

The WSL file can be accessed with {wsl.localhost}, but accessing it with that will create an errored network socket file that cannot be deleted again, so the PowerShell script version of Windows is deprecated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment