I’ve been doing all of my real (paid) work on VMs / containers for a while now but when it comes to writing Java code for some projects for university I stillneed to move away from using vim and install some full blown IDE in order to beproductive. This has been bothering me for quite some time but this week Iwas finally able put the pieces together to run NetBeans in a Docker container so that I can avoidinstalling a lot of Java stuff on my machine that I don’t use on a daily basis.
Run GUI apps and Firefox with Docker for Mac 2017. This article introduce how to run GUI apps and Firefox with Docker for Mac, the purpose is just for fun, maybe can be used for build Website test automation with docker, you can check this. All the commands below are tested with Docker 17.03.0-ce, macOS 10.12.3 and XUbuntu 16.04.2. Feb 12, 2016 - Perhaps slightly inspired by this blog by Jessica Frazelle I started putting some of the apps that I like to run on my Mac inside a container.
There are a few different options to run GUI applications inside a Dockercontainer like using SSH with X11 forwarding,or VNC but the simplest one that Ifigured out was to share my X11 socket with the container and use it directly.
The idea is pretty simple and you can easily it give a try by running a Firefoxcontainer using the following
Dockerfile
as a starting point:docker build -t firefox .
it and run the container with:If all goes well you should see Firefox running from within a Docker container.
Getting a NetBeans container up and running
Preparing a NetBeans base image was not that straightforward since we need toinstall some additional dependencies (namely the
libxext-dev
, libxrender-dev
and libxtst-dev
packages) in order to get it to connect to the X11 socketproperly. I also had trouble using OpenJDK and had to switch to Oracle’s Javafor it to work.After lots of trial and error, I was finally able to make it work and the resultis a base image available at the Docker Hubwith sources on GitHub.
Here’s a quick demo of it in action:
Future work
Over the next few months I’ll be working on a Play!app and will hopefully write a blog post on the workflow I used. Stay tunned for more :)
PS: This approach of sharing the X11 socket also be applied to vagrant-lxccontainers and I’ll document that on the project’s Wiki when Ihave a chance.
Reading Time: 6minutes
The Docker API has allowed for a plethora of options for interfacing with Docker, your containers, and images to emerge from CLIs to desktop applications and web-based management tools. I am a fan of graphical user interfaces and thought it was time to survey the current landscape of GUIs for interacting with Docker.
I will use the WordPress Docker Compose example to test each of these options, as it has multiple containers, sets up links and networks between them, and is sufficiently complex for an example.
Kitematic
Kitematic is the default GUI that ships with Docker for Mac and Windows. I won’t cover it in much detail as you likely know it well already. When Kitematic first emerged, it was one of the few GUI options available, and when Docker acquired the project in October 2015, I had high hopes for its development. Sadly, it has changed little since the acquisition, and it has remained in a permanent beta. ]
As it’s bundled by default, it’s a great way to get started with simple Docker applications and provides a convenient way to browse images on the Docker Hub or your account. I have found it a great way to learn Docker; you can create containers visually and then dig into the possible configuration options and understand what they are and do.
Portainer
Portainer(formerly UI for Docker) is a free open-source web application that runs as a container itself. You can install and start it with:
The
-v
flag isn’t mentioned by default, but you will need it to manage any local Docker containers. After creating a password and selecting the Docker instance to manage, you’re up and running.Portainer makes wide use of the Docker API to handle its interactions and monitoring, but for automation, also exposes its own API and template file format. Portainer covers most major areas of Docker you would want to interact with, offering creation, editing, management, monitoring and deletion of containers, as well as the ability to add, remove, and view images, networks, and volumes, but not edit them.
Here’s the example application visualized in Portainer, and the overview page for the WordPress container.
Helpfully, the overview page includes basic logging and monitoring features, giving an easy overview for troubleshooting. For remote clusters, you can also jump straight into a console straight in the browser.
Access levels
Portainer adds user management that lets you define the levels of access team members have to Portainer, and what aspects of Docker they can manage from within Portainer. The screenshot below shows restricting access to the Portainer container to a certain user and role.
Templates
App templates add a level on top of Dockerfiles and Compose files in a custom JSON format and allow you to create a Docker application using all the standard and custom functionality that Portainer offers. I’m not 100 percent sure how useful they are when compared to the standard Docker options, but from within the access control of Portainer, you might find them useful.
!Sign up for a free Codeship Account
Dockstation
Dockstation is another ‘native’ (well, Electron-based) application that looks a lot like Kitematic, but works from a different, ‘project’ perspective. You first create your project and set a docker-compose.yml file or a
docker run
command that starts your application.The application is in its early days with interface quirks (eg, after creating the project, the containers don’t actually start automatically) and lots of typos, but it has a couple of useful extra features that aren’t obvious.
Multiple Docker clusters
If you click the pencil icon next to the current cluster address, you will notice that you can add more, making Dockstation useful for managing more than one cluster in the same interface. It also provides a search field to look for particular images or containers across all those clusters.
Shipyard
With a similar set of features to the other web-based GUIs mentioned in this article, Shipyard provides an interface to your containers, images, and Docker instances. Start it running with this one command that handles multiple operating systems:
Start the sample application and then click on the WordPress container. You’ll see details about the container, plus buttons to stop, start, destroy, and debug the container.
Shipyard doesn’t offer many features that make it stand out from the other web-based GUIs. Its most comprehensive standout features are the container creation screen and the ability to add private repositories. Compared to the other web-based options, it was also the easiest to start and deploy, working perfectly on Docker for Mac.
Docker Compose UI
Specifically for adding a GUI to Docker Compose, the name says it all. Once again it runs in its own container:
Open your browser and you can create your own project from scratch or use one of the templates provided. To start the UI with a preexisting docker-compose.yml file, pass in the directory containing your file or run it in the directory.
MicroBadger
Not specifically for managing containers but for analyzing images, MicroBadger digs into image files to show the layers and commands within them, their dependencies, and their impact on your application.
![Gui Gui](/uploads/1/2/6/2/126292612/717910894.png)
For example, analyzing the WordPress image:
You can see that the largest dependency is for PHP, which isn’t surprising, and there’s not too much you can do about that. But it’s interesting to see the cumulative effect that every command has and where you might be able to shave off a few bytes. You can add badges to your image repositories to show potential users what the impact on their projects might be.
Rancher
While the tools I’ve mentioned so far are more designed for getting started with Docker images and containers, Rancher is a tool that takes what’s possible with a Docker GUI further and is more useful for production clusters. Reflecting this focus on production, Rancher is designed to work on Linux machines, so to test locally you might need to install onto a Virtual Machine.
Start the Rancher container using the following
docker run
command:I was also able to get it running on my Mac with the instructions here, but your mileage may vary.
Using Rancher offers more than the other options here but is also far more complex. For example, Rancher supports Docker Compose but extends it with Rancher Compose to add health checks, scaling, and other features. I was able to recreate the example application using Rancher’s ‘stacks’ feature by searching for ‘WordPress’. Within minutes, I had an active application consisting of the same parts. Throughout the interface are export options to create an appropriate YAML file for your Rancher stack.
Once you’re set up, then Rancher offers similar features to other web-based GUIs but offers interface elements to add the extra features that Rancher offers. For example, to change the number of WordPress instances, click the plus or minus icons on the container page. The normal resource constraints apply for scaling container instances, eg, you can’t have more than one container running on a Docker host that uses the same port as another.
If you ever lose track of how the components of your stack relate to each other, then Rancher offers handy graphs to show you.
As you might have guessed, Rancher is the option on this list that adds the most unique features. For many of you, it may offer far more than you need. Other features I’ve not mentioned include hosts insights, secrets management, a wide catalog of stacks, and Docker machine drivers.
Further into Orchestration
![Apps Apps](/uploads/1/2/6/2/126292612/317601734.png)
I intentionally kept this article about the Docker GUIs at the less complex end. However, it would be remiss of me to not mention the GUIs that ship with Docker orchestration tools such as Kubernetes and Mesos. Rancher starts to touch on their territory, but they go much further into deploying, managing, and orchestrating Docker containers in large-scale, complex applications.