Docker and NVIDIA-docker on your workstation: Integration with your DesktopWritten on April 26, 2017 by Dr Donald Kinghorn
In this series of posts I've been describing how to setup a usable configuration for running Docker containers on your workstation. We are treating containers the same as any other applications so why not integrate them with the desktop the same as other applications! In this post I'll show you how to add icons, menu items and click-able launchers for your Docker containers.
Here is a list of the previous post for reference,
I am using the Mate desktop on Ubuntu 16.04 for my setup but I am going to describe how to do this setup using standard XDG configuration files. Desktops that follow freedesktop.org standards should be able to use the files we create. (...and that is just about every desktop in existence!)
Directories for configuration files
You should make note of where files for desktop configuration are located.
/etc/xdg/-- The system config directory (system .menu files are there)
$HOME/.config/-- Your local/personal config directory
/usr/share/applications/-- System .desktop files
$HOME/.local/applications/-- Your added .desktop files
/usr/share/desktop-directories/-- Directory entry .directory files
$HOME/.local/desktop-directories/-- You guess it :-)
I will be making changes only in the
Creating .desktop files for "click-able" Docker applications
Lets start by creating a .desktop file for Tensorflow with GPU acceleration. [I'm assuming that you have a Docker and NVIDIA-Docker configuration as I have described in earlier posts.]
The Exec line has the the startup command for the container. That is the most important part! You may want to change that if you don't like the options I chose. (The part in quotes can aslo be used directly on the command line.)
.desktop file for Tensorflow
Create a file with the following text in
Note 1: [For the Exec statement I used
mate-terminal since that is the terminal app I am using on my desktop. You could use gnome-terminal or whatever terminal you are using by default. Also, I called bash -c to run
nvidia-docker so that the
$HOME shell variable would resolve correctly.]
Note 2: [ I used port 8899 on my host because I often have Jupyter running on it's default port which is 8888. The Tensorflow container starts up with a message like
The message refers to the container port 8888. You would need to use port 8899 on your host. (I wish Tensorflow wouldn't have used such a common port for this!!) ]
You can put an icon in
$HOME/.local/share/icons/tensorflow.png. I used this
If you now check your application menu there should be an entry for your Tensorflow Docker app.
Clicking on that should start up Tensorflow in a Jupyter notebook with CUDA GPU acceleration.
With what we did above you could now right click on that menu item and add a desktop or panel link.
Creating a menu folder for Docker containers
Lets go ahead and add a new top-level item for our Docker apps rather than using the generic catch all "Other".
Check to see if the directories
$HOME/.config/menus exist. If not create them with
Then create the file
$HOME/.local/share/desktop-directories/dockerapps-DockerApps.directory with the following content,
I have added this icon to
Next create the file
$HOME/.config/menus/mate-applications.menu with the this XML,
Note: This file is prefixed with "mate" other desktop environment names could be used. [ I may revisit this issue.]
Now we need to add something to the new DockerApps category before it will show on our menus. We will add
Category=DockerApps to the end of our .desktop file for Tensorflow. The complete file is now,
The menu now looks like the following (with the addition of the other .desktop files listed below),
More .desktop files
CUDA 8 with OpenGL and desktop diaplay
Happy computing! --dbk