How to Manage Docker Containers using Portainer on Ubuntu
Portainer is an open-source management UI for Docker, including Docker Swarm environment. Portainer makes it easier for you to manage your Docker containers, it allows you to manage containers, images, networks, and volumes from the web-based Portainer dashboard.
In this tutorial, I will show you step-by-step how to install and configure Portainer on Ubuntu 16.04 LTS. We will install and configure Portainer, deploy the Apps Container, Manage Container, images, network, and volumes for our Docker environment.
- Ubuntu Server 16.04
- Root privileges
What we will do
- Install Docker on Ubuntu 16.04
- Install and Configure Portainer
- Deploy Ghost Blog App Container
- Docker Environment Management
Step 1 – Install Docker on Ubuntu 16.04 LTS
Before installing docker packages, please update the repository on your system and upgrade packages.
sudo apt update
sudo apt upgrade
Now install docker using the apt command below.
sudo apt install docker.io -y
After the installation is complete, start docker service and enable it to launch everytime at system boot.
systemctl start docker
systemctl enable docker
Docker installed on ubuntu 16.04 server, check it using the command below.
And you will get the docker version 1.x installed on the system.
Step 2 – Install and Configure Portainer
Portainer can be installed as a docker container and standalone without docker container.
In this tutorial, we will install Portainer as a Docker container. It’s really simple to install and run on any system because we just need to ensure the system support for Docker.
Before installing Portainer, download the Portainer image from the DockerHub using the docker pull command below.
docker pull portainer/portainer
Now run Portainer using the simple docker command below.
docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer
Portainer is now running as a container, check it using the docker ps command.
And you will get the result as below.
Portainer is now running as a Docker container with the name ‘elatted_hopper’, and it’s running under port 9000.
Next, we will configure the Admin password for the Portainer.
Open your web browser and type the server IP address with port 9000.
You will get the page about the admin user and password configuration.
Type your strong admin password and click the ‘Create user’ button.
Now we need to define which environment Portainer will connect. Portainer offers support for standalone Docker environment, Docker Swarm, and Swarm mode.
For this guide, we will configure Portainer to connect to the local Docker environment.
Choose the ‘Local’ environment and click ‘Connect’ button.
And now you will see the Portainer Admin Dashboard.
Portainer has been installed as a Docker Container on Ubuntu 16.04.
Step 3 – Deploy New App Container
After the Portianer installation, we will run the Application Container using Portainer.
Click the ‘App Template’ menu.
Now choose the application that you want to install. For this guide, we will install the ‘Ghost’ blog as a Docker Container.
Type the container name ‘ghost-blog’ and click the ‘Show advanced options’. On the ‘Port mapping’ configuration, type port 80 on the ‘host’.
Now click ‘Deploy the container’ button.
And when it’s complete, you will get the container page as below.
Ghost is now installed as a Docker Container and it’s using port 80 on the host.
Open your web browser and type the server IP address.
And you will get the ‘Ghost’ blog homepage as below.
Step 4 – Manage Docker Environment Using Portainer
In this step, we will configure Docker Environments such as Docker images, Container, Volumes, and Networks.
Portainer provides a simple and easy way to use management for Docker Containers.
Click the ‘Containers’ menu on the left and you will get the page as below.
We can start, stop, restart, create a new container, access the shell of the container, see the container log, and stats of the container from this Portainer container management.
Shell of the Ghost container:
Ghost container logs:
The container stats:
Manage Docker Images
Click the ‘Images’ menu and you will get the page as below.
Now we can see the list of docker images on our system, and we can create manually a new docker image, or pull/download new images from the DockerHub repository.
From this menu, we create new custom networks for our Docker environment. Click the ‘Networks’ menu.
This menu provides an easy way to create new custom volumes for our container.
We just need to create new custom volumes, and when we want to create new container the application, just attach it to the container through the ‘Advanced options’ menu.
Installation and configuration of the Portainer Docker Management UI on Ubuntu 16.04 has been completed successfully.