If there’s a Docker container you run a lot it’s nice to be able to single-click an icon on the desktop to run it. This is particularly useful if the container has an interactive shell.
Here’s how to do that for the Unity desktop (Ubuntu 15.04), using the Azure-CLI container as an example. Using this I can click on the desktop any time I want to start a new Azure CLI container. I can type exit in the container to shut it down, or just close the terminal window if I want to attach to it later.
The basic steps are:
- Make sure Docker is installed. See http://docs.docker.com/installation/ubuntulinux/
- Create a docker group and add yourself to it so you don’t have to sudo each time you want to run docker:
groupadd dockersudo usermod -g docker myuserid
Reboot, or at least restart the desktop so when you start a terminal in Unity and run “groups” it says you’re in the docker group.
- Create a script to run your docker container. In my case it looks like this:
#!/bin/bash docker run -it microsoft/azure-cli
Make sure the script is executable:
sudo chmod a+x /opt/azure-cli.sh
- Save the script somewhere e.g.: /opt/azure-cli.sh
- Copy the image you want to use as an icon to /usr/share/icons. E.g. find a small image you want to use on the web and Save-As from your browser to this directory.
- Create a desktop file for your container app, and make the “Icon” entry point to your image, and the “Exec” entry point to your script. E.g. for the Azure-CLI container:
sudo vi /usr/share/applications/azure-cli.desktop [Desktop Entry] Name=Azure-CLI Comment= Exec=/opt/azure-cli.sh Icon=/usr/share/icons/azure.png Terminal=true Type=Application StartupNotify=true
- Go to /usr/share/applications in the file manager and drag your icon for your container app into the launcher bar. You can go there directly with this command:
nautilus /usr/share/applications &
When you run the container, in the case of Azure-CLI you’ll be in the interactive shell. E.g. after launching and typing “azure login”:
The following article on adding Minecraft to the Unity launcher was very helpful in figuring out how to do this for Docker containers: