Signup/Sign In
LAST UPDATED: JULY 26, 2023

Introduction to Portainer - Docker made easy!

    Have you ever been confused with docker command and wonder if there could a Graphical interface for the same? If yes, stick to the end of this article, and we will discuss a tool, Portainer, which solves this problem.

    Portainer is a web-based graphical user interface for managing Docker containers, images, volumes, networks and more. It can perform everything which docker-cli can do with support of Docker standalone, Kubernetes, Docker Swarm and Azure ACI environments.

    Portainer uses and feature chart

    In this article, we will show you how to set up Portainer on your system. It is smooth and easy to use after proper setup.

    How to Install Portainer?

    Portainer is itself installed as a Docker container, which makes it stinking easy to deploy anywhere. Its image is available as an Official Docker container on Docker hub.

    You need to have Docker (19.01 or higher) installed and running on your system to install Portainer. Verify the Docker version using docker --version command in a terminal. More info here.

    To install Portainer, you need to create a new Docker volume and start a new Portainer container. Portainer uses the volume (persistent storage) to store its application data.

    To create a new Docker volume, run the following command in a terminal:

    docker volume create portainer_data

    This will create a volume named portainer_data. You can list all the volumes on your machine by running docker volume ls.

    To start a new Portainer container, run the following command in a terminal:

    docker run -d -p 9443:9443 -p 8000:8000 --name=portainer --restart=unless-stopped -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest

    Here is what this command does:

    • It will pull the portainer/portainer-ce (latest) image and start a new container from it
    • Container will be detached (-d) and will run in the background
    • Web UI is exposed on port 9443 (HTTPS) on the host machine, which is bound to port 9443 within the container (-p 9000:9000)
    • Container can be accessed with its name, portainer (--name=portainer)
    • Container will restart automatically unless it is explicitly stopped (--restart=unless-stopped)
    • A Host Docker socket is mounted into the container (-v /var/run/docker.sock:/var/run/docker.sock) which allows Portainer to access and manage the Docker resources on the host machine
    • Volume created earlier is mounted to /data within the container (-v portainer_data:/data)

    To check the status of the container, use docker ps command.

    Install Portainer in Linux using command line

    If the output of the commands you run is similar to the above screenshot, we are ready to access Portainer's web interface.

    Access Portainer Interface

    You can finally access Portainer by visiting https://127.0.0.1:9443 in browser.

    It requires to set a password for the admin user upon first use. Enter a strong password and click Create user.

    Portainer login screen

    You will then land on the Home page of Portainer interface.

    Here, you can see the list of endpoints, or Docker environment that Portainer can manage, that Portainer can connect to. By default, there is only one endpoint, which is the local Docker instance on your machine.

    Here, you can see an overview of containers, images, volumes, networks and other resources.

    Portainer dashboard

    Feel free to play with the interface and become familiar with the features and controls it provides.

    FAQs

    Here are some possible questions you might have related to Portainer:

    Q. How can I access Portainer remotely?

    You can access Portainer remotely by exposing port 9443 on your host machine or forwarding it via SSH.

    Alternatively, you can use Portainer Agent, which is a lightweight container that runs on each remote server and communicates with Portainer via a secure Web Socket connection.

    Portainer Agent

    Q. How can I update Portainer to the latest version?

    You need to stop and delete the existing container, pulling the latest image and starting a new Portainer container with the same parameters as given below:

    docker stop portainer
    docker rm portainer
    docker pull portainer/portainer-ce
    docker run -d -p 9443:9443 -p 8000:8000 --name=portainer --restart=unless-stopped -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce

    Conclusion

    Overall, Portainer is a convenient and powerful open source tool for managing Docker resources using a web-based user interface. It helps you visualize and control containers, images, volumes, networks and more. It supports Docker Standalone, Kubernetes, Docker Swarm and Azure ACI environments on every platform.

    Portainer also makes it easy to create and manage containers and stacks using YAML files and has many other features that we didn't cover in this article, such as users, teams, extensions and more.

    Pradeep has expertise in Linux, Go, Nginx, Apache, CyberSecurity, AppSec and various other technical areas. He has contributed to numerous publications and websites, providing his readers with insightful and informative content.
    IF YOU LIKE IT, THEN SHARE IT
    Advertisement

    RELATED POSTS