THE DIGITAL LIFE

THE DIGITAL LIFE

THE DIGITAL LIFE

Portainer install Ubuntu tutorial – manage your docker containers

Portainer CE is a free and open-source tool that manages all your docker containers. It has a nice clean web UI where you can inspect and control all your docker resources. With this tutorial, you can install Portainer easily on Ubuntu with a simple docker run command, use a docker-compose file, or even deploy it in a Kubernetes environment. In this tutorial, let’s have a look at how to install Portainer on an Ubuntu server.


Install Portainer on Ubuntu tutorial

First, you need to install Docker on Ubuntu. I’ve made a video about it, or you can just follow the official docker documentation. If you want to install Portainer with docker in a cloud environment, I can recommend DigitalOcean. They have a pre-build Droplet image with Ubuntu and Docker already installed.

First, let’s create a new volume to store the data persistently.

docker volume create portainer_data

Then we can simply launch the Docker container.

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-ce

(Optional) Reverse Proxy with NGINX Proxy Manager

I recently made a tutorial about deploying the NGINX Proxy Manager as a reverse proxy, watch it first! You can use this to obtain trusted SSL certificates and expose Portainer securely. Note, that when you want to use NGINX Proxy Manager with Portainer, you need to put both containers in the same network, and don’t expose the admin port 9000. Here is a slightly modified version of the docker command to run Portainer with the NGINX proxy manager.

docker run -d -p 8000:8000 --network nginxproxymanager_default --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce

After deploying the portainer container, you can open NGINX Proxy Manager and create a new proxy host that will expose port 9000 of Portainer securely with letsencrypt certificates.

NGINX proxy manager web UI

Login to the Portainer web UI

When you first log in to the Portainer web UI on port 9000, you need to create a password. After setting up this you need to select your environment. You can choose to manage the local Docker environment (this is what we want to do). But you can also manage any local Kubernetes environment or connect to the Portainer Agent, to manage remote servers.

Select the local Docker environment and connect.

Portainer environment

Now, you should see the Home Dashboard. If you connected remote servers through “Endpoints”, you see all your servers here. We only have connected Portainer to the local Docker environment. If you’re running Portainer with NGINX Proxy Manager you will notice that we’re already running 3 containers. That is because Portainer can manage all existing Docker resources, even if you haven’t deployed them via Portainer, but terminal commands or compose files.


How to deploy containers with Portainer

With Portainer, you can easily create new docker resources. But the best feature compared to Docker terminal commands is, that you can also edit or change your existing resources. You can also monitor your running containers, start and stop them, and so on.

App Templates can help you to quickly deploy applications with pre-defined volumes, environment settings, and so on. For example, you can simply deploy databases, webservers, or well-known applications.

Before creating a container you need to add all networks or volumes, you want to use, first. This is pretty easy and straight-forward if you’re familiar with the concepts of Docker and containers.

Volumes in Portainer

Creating volumes in portainer

Networks in Portainer

Creating networks in portainer

Containers in Portainer

Creating containers in portainer

Deploy docker-compose stacks with Portainer

You can also deploy docker-compose files with Portainer in so-called “stacks”. You can use the web editor to simply copy and paste a compose file. Upload it from your computer. Use a Git Repository, or use a custom template.

You can also browse existing templates or define custom ones if you want to define some recipes for containers that you usually deploy often.

You can also manage existing stacks, you have deployed with docker-compose manually on the system. For example, if you followed my NGINX Proxy Manager tutorial with docker-compose, you should see the stack. However, because Portainer is not fully managing the compose file, the access is limited.

portainer stacks limited access

Stacks in Portainer

Creating Stacks in portainer

What else?

3 thoughts on “Portainer install Ubuntu tutorial – manage your docker containers”

  1. I have a docker-compose. yml file. that works fine. But when I will use the NGINX Reverse Proxy I need to add the nginxreverseproxy_default newtwork I get an error. How do I set the network to this docker-compose.yml. The NGINX Proxy will be installed later. So the nginxreverseproxy_default newtwork is by the first installation not available.

    Here is my docker-compose.yml

    version: ‘3’

    services:
    portainerservice:
    image: portainer/portainer:latest
    volumes:
    – portainer_data:/data
    – /var/run/docker.sock:/var/run/docker.sock
    restart: always
    ports:
    – “9000:9000”

    volumes:
    portainer_data:

    Reply
  2. Hello,
    I have the installation of docker on my Ubuntu 20.04 server.
    I updated and restarted Ubuntu server and NGINX is no more running,
    I tried to create new stack but I received the error message.
    Failure
    driver failed programming external connectivity on endpoint nginxproxymanager_app_1 (082f86ff640393ba83175df4abfd377e60e34be96d92555719c89d7262ba0f65): Error starting userland proxy: listen tcp4 0.0.0.0:80: bind: address already in use
    I do not have any ide how to fix the issue.
    I have only 2 running dockers on the server:
    -InfluxDB
    -Portainer.
    Thank you for an answer.

    Reply

Leave a Comment

I accept the Privacy Policy