At this point, it’s nearly impossible to avoid using containers in your company. There are plenty of reasons for the rise of containers (flexibility, portability, reliability, etc.); but no matter your reasons, you are probably using Docker as your primary container platform. If that’s the case, you may have been looking for a web UI that will allow you to manage your containers from any browser that can reach your network.
Good thing there’s Portainer, an open source, lightweight management UI for Docker. With Portainer you can pull images, add containers, add networks, and so much more. This tool is really quite remarkable and should be considered by anyone that manages a Docker system.
I want to walk you through the installation and logging into Portainer. I’ll be demonstrating on a Ubuntu Server 16.04 platform, running the latest installation of Docker. What is really unique about Portainer is that it itself is a Docker container, so we’re going to have a bit of recursive fun.
As I mentioned, Portainer is a container; so the installation isn’t so much an install as it is a pull. So open up your terminal window (or log into your Docker headless server) and issue the following command:
sudo docker run -d -p 9000:9000 portainer/portainer
That command will pull down all of the necessary images and create the Portainer container. Issue the command sudo docker ps and you should see the necessary containers running (Figure A).
After the command runs, open up a browser and point it to http://SERVER_IP:9000 (where SERVER_IP is the IP address of the server housing Portainer. Once your browser lands on the page, the first thing you will have to do is set (and verify) a password for the admin user (Figure B).
Upon successfully creating the password, you will then have to point Portainer to the Docker server (Figure C). You don’t have to have Portainer running on the same server as is Docker (in my instance, for example purposes, I have). Give the connection a name and then enter the endpoint URL (which will be http://SERVER_IP:2375 – Where SERVER_IP is the address of your Docker server).
Click Connect and you will find yourself on the Portainer web UI manager (Figue D).
If you find yourself unable to connect Portainer to your Docker server (be they one and the same or not), I have found a rather clunky workaround. Issue the following command to download a script to pull Shipyard (this is run on your Docker server):
Give the script executable permissions with the following command:
chmod u+x deploy
Run the script with the command:
Once that script finishes up, you should then be able to connect Portainer to your Docker server.
At this point, everything should be self-explanatory. Click on the Images tab to see what images you have already pulled onto the machine and search for new images to pull. Click on the Containers tab to see what containers are running or create a new container. You might also want to head over the Users section and create new users. You can create both administrative users and standard users.
You can also connect new Docker servers to Portainer. To do this, click on the Endpoints tab and then (in the top pane – Figure E), type a name for the new endpoint and add the IP Address of the new Docker server (with port 2375). Click Add endpoint and your new Docker server will be added.
Note: If you have any trouble connecting new endpoints, running the Shipyard work-around (on the endpoint server) should solve the problem.
Easy Docker management
You’ll be hard-pressed to find an easier web-based UI for Docker management. Once you’ve started using Portainer, you might find yourself not wanting to go back to the Docker command line interface.
Subscribe to the Developer Insider Newsletter
From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays