This is a docker cookbook of sorts.
Launching a GUI application with docker
My final object is to run the
gnuradio-companion GUI through a docker container.
Because GNURadio loves to muck up the entire system regardless of the OS used. It also doesn’t like to live in non-standard directories (most tools then fail to run) which leaves out the option os a parallel install. So containerization is probably the right option :-/
Here was my timeline
- Check if there is a
gnuradiodocker image available.
I checked available images with
docker search gnuradioand found
marcelmaatkamp/gnuradioto be a promising option 1.
What finally worked
docker run -e DISPLAY=host.docker.internal:0 --entrypoint gnuradio-companion -it marcelmaatkamp/gnuradio
- The -t flag is not necessarily required but gives GNURadio debugging outputs
Check which docker images are installed
Find the ID or names of currently running containers
docker -s -qa will provide the names of containers without additional info. Useful to combine with other docker commands like
docker stop and
docker stop <container name or ID>
Convenient way to stop all running containers docker stop $(docker ps -qa)
Note: only stopped containers can be removed.
docker rm <container name or ID>
Convenient way to remove all stopped container docker rm $(docker ps -qa)
Remove the downloaded docker image
Note: Images can only be removed if there are no running or stopped containers using this image
docker rmi <image name>
Trying to launch a simple GUI image called
Before we can run a docker GUI, we need to add localhost to allowable connection list for the X window server.
xhost + 127.0.0.1 Or xhost + localhost
Then run the docker container (using the default script) docker run -e DISPLAY=host.docker.internal:0 gns3/xeyes
What is happening here?
host.docker.internal:0 is the IP address of the computer (and port) where the X server is running
How to explore the contents of a docker container? docker run –rm -it –entrypoint=/bin/bash name-of-image
The rm flag automatically removes the container after it exits
Taking a snapshot of a container
# find ID of your running container: docker ps -a # create image (snapshot) from container filesystem docker commit 12345678904b5 mysnapshot # explore this filesystem using bash (for example) docker run -t -i mysnapshot /bin/bash # remove snapshot after we’re done docker rmi mysnapshot
Note: exec is used to run another command in an already running container.
docker exec -it <running container name or ID> bash