Last active
August 18, 2022 08:59
-
-
Save cristiklein/a7cc73e30a0d944e31e1b511a54e9091 to your computer and use it in GitHub Desktop.
Open browser window in the host from a container
This file contains hidden or 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
FROM ubuntu:22.04 | |
RUN apt-get update && apt-get install -y \ | |
socat \ | |
&& rm -rf /var/lib/apt | |
COPY x-www-browser /usr/bin/x-www-browser | |
RUN chmod +x /usr/bin/x-www-browser |
This file contains hidden or 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
#!/bin/bash | |
socat \ | |
unix-listen:/run/user/$(id -u)/ck8s-open-browser.sock,fork \ | |
system:'xargs xdg-open' & | |
docker build -t ck8s-open-browser-demo . | |
docker run \ | |
--rm \ | |
-ti \ | |
--net host \ | |
-e PATH=$PATH \ | |
-v $HOME:$HOME \ | |
-w $HOME \ | |
-u $(id -u):$(id -g) \ | |
-v /etc/passwd:/etc/passwd:ro \ | |
-v /etc/group:/etc/group:ro \ | |
-v /etc/ssl/certs:/etc/ssl/certs:ro \ | |
-v /run/user/$(id -u)/ck8s-open-browser.sock:/run/user/$(id -u)/ck8s-open-browser.sock \ | |
ck8s-open-browser-demo |
This file contains hidden or 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
#!/bin/bash | |
echo "Trying to open $1 in host browser" >&2 | |
echo $1 | socat stdio unix:/run/user/$(id -u)/ck8s-open-browser.sock |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment