wsl2 verified
This commit is contained in:
parent
f4e1e1a4f4
commit
4408814749
17
README.md
17
README.md
@ -2,20 +2,21 @@
|
|||||||
Here you can find simple gstreamer dockerfile and necessary scripts to work with GUI.
|
Here you can find simple gstreamer dockerfile and necessary scripts to work with GUI.
|
||||||
Scripts will not work on windows directly. It is assumed that you will be using WSL for work.
|
Scripts will not work on windows directly. It is assumed that you will be using WSL for work.
|
||||||
|
|
||||||
Other way, would be using run.bat script as shown under this thread
|
Because I wasn't able to start it up without running directly from WSL2 :D
|
||||||
|
But there are someone who was able to do this:
|
||||||
https://stackoverflow.com/questions/73092750/how-to-show-gui-apps-from-docker-desktop-container-on-windows-11
|
https://stackoverflow.com/questions/73092750/how-to-show-gui-apps-from-docker-desktop-container-on-windows-11
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
1. Run build.sh script with container name: e.g.
|
1. Start run.sh script with -b flag (build):
|
||||||
- `build.sh gstreamer-base`
|
- `run.sh -b`
|
||||||
2. Run run.sh script with same container name: e.g.
|
- _you can just use run.sh if image already built
|
||||||
- `run.sh gstreamer-base`
|
- you can specify image name with -c flag_
|
||||||
- if you're using Windows you can try (to be fair, I don't know much about powershell scripting, so this is generated by AI):
|
2. In opened bash verify that gui is opening correctly:
|
||||||
- `run.ps1 -ContainerName gstreamer-base -Build`
|
|
||||||
3. In opened bash verify that gui is opening correctly:
|
|
||||||
- `gst-launch1.0 videotestsrc ! autovideoconvert ! autovideosink`
|
- `gst-launch1.0 videotestsrc ! autovideoconvert ! autovideosink`
|
||||||
|
|
||||||
|
_Note: if you are using wsl2 you should see wsl=true line in terminal_
|
||||||
|
|
||||||
If video sink is not visible on the screen:
|
If video sink is not visible on the screen:
|
||||||
1. Make sure that wsl2 is active.
|
1. Make sure that wsl2 is active.
|
||||||
2. Make sure that WSLg is supported (should be built-in on windows 11)
|
2. Make sure that WSLg is supported (should be built-in on windows 11)
|
||||||
8
build.sh
8
build.sh
@ -1,8 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
if [[ $# -ne 1 ]]; then
|
|
||||||
echo "using: $(basename $0) <container name>"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
docker build -t $1 .
|
|
||||||
29
run.ps1
29
run.ps1
@ -1,29 +0,0 @@
|
|||||||
param(
|
|
||||||
[string]$ContainerName = "gui-app-container",
|
|
||||||
[switch]$Build
|
|
||||||
)
|
|
||||||
|
|
||||||
if ($Build) {
|
|
||||||
Write-Host "Building Docker image: $ContainerName" -ForegroundColor Green
|
|
||||||
docker build -t $ContainerName .
|
|
||||||
|
|
||||||
if ($LASTEXITCODE -ne 0) {
|
|
||||||
Write-Host "Build failed!" -ForegroundColor Red
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$dockerCommand = @(
|
|
||||||
"run", "-it", "--rm",
|
|
||||||
"--name", $ContainerName,
|
|
||||||
"-v", "/tmp/.X11-unix:/tmp/.X11-unix",
|
|
||||||
"-v", "/run/desktop/mnt/wslg:/mnt/wslg",
|
|
||||||
"-e", "DISPLAY=$DISPLAY",
|
|
||||||
"-e", "WAYLAND_DISPLAY=wayland-0",
|
|
||||||
"-e", "XDG_RUNTIME_DIR=/mnt/wslg/runtime-dir"
|
|
||||||
)
|
|
||||||
|
|
||||||
$dockerCommand += $ContainerName + " bash"
|
|
||||||
|
|
||||||
docker @dockerCommand
|
|
||||||
59
run.sh
59
run.sh
@ -1,13 +1,56 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [[ $# -ne 1 ]]; then
|
usage() {
|
||||||
echo "using: $(basename $0) <container name>"
|
echo "usage:
|
||||||
exit 1
|
$(basename $0) -c <container name> -b
|
||||||
|
default container name is gstreamer-base
|
||||||
|
"
|
||||||
|
}
|
||||||
|
|
||||||
|
build=False
|
||||||
|
container_name="gstreamer-base"
|
||||||
|
|
||||||
|
while getopts ":bhc:" opt; do
|
||||||
|
case $opt in
|
||||||
|
b)
|
||||||
|
build=True
|
||||||
|
;;
|
||||||
|
h)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
c)
|
||||||
|
container_name=$OPTARG
|
||||||
|
;;
|
||||||
|
\?)
|
||||||
|
echo "Invalid option: -$OPTARG" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
:)
|
||||||
|
echo "Option -$OPTARG requires an argument (getopts)" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $build = "True" ]; then
|
||||||
|
docker build . -t $container_name
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker run -it \
|
wslgPath=""
|
||||||
-v /tmp/.X11-unix:/tmp/.X11-unix \
|
|
||||||
-v $HOME/.Xauthority:/root/.Xauthority \
|
|
||||||
-e DISPLAY=$DISPLAY \
|
|
||||||
$1 bash
|
|
||||||
|
|
||||||
|
# we are running in wsl?
|
||||||
|
uname -a | grep -qi wsl && wsl=True
|
||||||
|
|
||||||
|
if [ $wsl = "True" ]; then
|
||||||
|
echo "wsl=true"
|
||||||
|
wslgPath="-v /mnt/wslg:/mnt/wslg"
|
||||||
|
fi
|
||||||
|
|
||||||
|
docker run --rm -it \
|
||||||
|
-v /tmp/.X11-unix:/tmp/.X11-unix $wslgPath \
|
||||||
|
-v $HOME/.Xauthority:/root/.Xauthority \
|
||||||
|
-e DISPLAY \
|
||||||
|
-e WAYLAND_DISPLAY \
|
||||||
|
-e XDG_RUNTIME_DIR \
|
||||||
|
$container_name bash
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user