Portainer Docker: Simplifying Container Management

Sohail
Sohail

Table of Contents

Our previous article discussed Docker. If you are not familiar with Docker containers, you should learn about them. Docker containers can be useful for developers. Docker packages are widely available and simple to install in almost all distribution repositories. However, managing them can be difficult, especially for those who dislike the command line.

Portainer Docker

Portainer Docker lets you manage Docker containers across multiple platforms. Linux distributions can easily install it, and the web-based GUI front-end is extremely user-friendly. We may write detailed articles on the portainer’s various features in the future. However, for now, we’ll learn how to install and configure the portainer on Linux.

How to install Portainer in Ubuntu?

Before pulling portainer to our system, install Docker in your system. You can use your distribution package manager to install docker in your distro.

  • First of all, update your system.
sudo apt update
sudo apt upgrade
  • Install Docker
sudo apt install docker.io
  • Install portainer
sudo docker volume create portainer_data
docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
sudo docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer

Install Portainer in Manjaro or Arch Linux

You can follow the above method to install portainer in Manjaro. But portainer is also available in the Arch User Repository and it’s build is regularly updated with the latest release.

Portainer is available in the Arch User Repository so you can easily install portainer in Manjaro or Arch Linux. Arch

sudo pamac build portainer-bin

And that is it. Now portainer is installed and running on port 9000. To access the dashboard, visit 127.0.0.1:9000 in your browser.

When you visit 127.0.0.1:9000 for the first time, it will redirect to create a user. Enter the username, strong password and click “Create user”.

Portainer.io set up admin password
Portainer.io set up admin password.

The next step is to connect to the Docker environment. You can connect portainer with a remote server, Microsoft Azure server, or connect to a portainer agent. In this example, we will connect our local and remote docker environment with portainer.

Mostly we do not have to do anything to connect to our local environment. Just select the local environment and click Connect and portainer will automatically configure and connect to the local environment.

Select “Local” and click “Connect”.

Portainer.io connect to docker
Portainer.io connect to docker.

You have connected portainer with the local Docker environment. You can now manage the docker environment with this easy-to-use application. Click on the connection “local” and it gets to the dashboard.

Portainer.io homepage
Portainer.io homepage

Connect Portainer Docker With Remote Docker Environment

It was simple to connect to the local Docker environment. We must first configure our remote Docker server before connecting to our remote Docker environment.

Expose Remote Docker Api

We need to expose our remote docker API in order to connect to it. Using SSH, connect to your remote server.

Once logged in, create the configuration at /etc/systemd/system/docker.service.d/remote-api.conf.

sudo nano /etc/systemd/system/docker.service.d/remote-api.conf

Now paste the following in the file –

[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock

Now press Ctrl + O to save the file and Ctrl + X to exit. Take note of the port number 2375, which will be used to connect to this docker from portainer.

sudo systemctl daemon-reload
sudo service docker restart

or 

sudo systemctl restart docker 

Now the configuration part is done. Open portainer in the web browser, click Endpoints from the sidebar, and Add environment. Select Docker from the Environment type.

Create environment
Create environment

Now fill all the required environment details.

Environment details
Environment details
  • Name: The environment name to show on the dashboard
  • Environment URL: The IP address of your remote server with the port we configured on the remote server. i.e. 192.168.29.34:2375.

If you want to use TLS, then toggle it on and upload the certificates. Rest of the fields are optional. Finally, click Add environment. If your remote server is configured as show above, you’ll see the success message.

Portainer dashboard
Portainer dashboard

From the dashboard, you can see and manage the number of stacks, containers, images, volumes, and networks.

Dashboard
Portainer Dashboard

One of the most useful features of Portainer is that you can easily launch a Docker app. There are various app templates available to launch your application on Docker.

To create an app, navigate to “App Templates” and click on the app you want to launch.

Portainer App templates
Portainer App templates

Below you can see how easy it is to create an app. Select the app, fill in the details, and click Deploy.

Create docker container
Create docker container

Currently, portainer has 41 app templates available. These templates include CMS, DBMS, web servers, file manager, registry manager, and many more.

Conclusion

Docker is a useful tool for developers, and portainer makes it extremely simple to use. In subsequent articles, I will go over more portainer features in depth. If you have any questions about any of the above steps, please leave them in the comments section below.

DockerSystem AdministrationUncategorizedreview