Networking

How to install and use Portainer for easy Docker container management

Looking for an easy to use web interface for Docker container management? Here's how to get Portainer up and running for just this purpose.

dockernewhero.jpg
Image: Jack Wallen

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.

Installation

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).

Figure A

Figure A

The Portainer containers running and ready to go.

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).

Figure B

Figure B

Creating a password for the Portainer admin user.

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).

Figure C

Figure C

Connecting Portainer to your Docker server.

Click Connect and you will find yourself on the Portainer web UI manager (Figue D).

Figure D

Figure D

The Portainer Docker manager UI.

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):

wget https://shipyard-project.com/deploy

Give the script executable permissions with the following command:

chmod u+x deploy

Run the script with the command:

sudo ./deploy

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.

Figure E

Figure E

Adding a new Docker server as an endpoint.

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.

Also see

About Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.

Editor's Picks

Free Newsletters, In your Inbox