Get Started with Docker - Part 4: Portainer : How To Deploy Containers The Easy Way
Tags: docker, tutorial, devops
Published: 2024-03-10 12:36:53

If you've been following along so far then you've already managed to get Docker installed on your system and your first Docker container service deployed.

A lot of Docker management can be done through the command line and a lot of people like working with docker compose files and docker run commands in the terminal but this can start to get overly complicated.

<img width="100%" style="width:100%" src="https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExcjBlYnZqcWF4OTlnbXhsNW05MGR0aWJ1cTQ1YTdoMXJlMndwOTBsYiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/Gh5lck3oM8H1zivsRI/giphy.gif">

I started out by using **Portainer** which was a great way to get started with lists of community maintained, curated apps to install with a simple point and click web browser based dashboard. Making it easy to try out loads of different containers quickly from one of theses lists or your own without having to use the terminal.

___

In this guide, we'll spin up one of the most best ways to manage, deploy and mantain your docker containers from an easy to use Web UI.

We'll be

-   Looking at What Portainer is
-   Going to the project page for Portainer for our build and install instructions
-   SSH into the host machine where Docker is installed
-   Creating a Docker Volume for Portainer Data
-   Spin up and deploy our Portainer Docker Container
-   Configure New Portainer Environment
-   What Are Stacks
-   Set up the Portainer App Store (App Templates)
-   Customise and deploy a stack from the Portainer App Store

___

## What's Portainer?

Portainer is a lightweight management toolset that allows you to easily build, manage, and maintain Docker and Kubernetes environments.

Once deployed and connected to your docker network, you will have a running web service that you can access to help see your running Docker containers.

You can click into your running containers to check out the logs, stop, start or change variables to redeploy.

The main attraction though is the list of ready to use Docker Containers that are included by default but can be added to by custom XML files in the Settings.

There are some drawbacks with managing containers you have deployed using Docker Compose but you can always redeploy in Portainer if you want to manage everything from here.

___

## Portainer Project Page

Portainer is available to license for Business Use but we'll be using the Community Edition.

[Portainer Github](https://github.com/portainer/portainer/)

___

## SSH into Docker Install

In this guide we're using a Raspberry Pi running Ubuntu Server Minimal. If you need help with setting that up with docker on your Raspberry Pi then check out the guide below

[Get Started with Docker - Part 2a - Raspberry Pi Linux Install Guide](https://dev.to/reprodev/get-started-with-docker-part-2a-raspberry-pi-linux-install-guide-4hl9)

Alternatively, you can run the same commands on WSL using Docker Desktop on a Windows machine if you prefer with the guide below

[Get Started with Docker - Part 2b - Windows Docker Desktop Install Guide](https://dev.to/reprodev/get-started-with-docker-part-2b-windows-11-install-guide-wsl-and-docker-desktop-edition-2o2f)

<img width="100%" style="width:100%" src="https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExZG1vZDUwOTFxZWZueWN4bWNxcmlkZzR5cWs3ODVnNGpnMmNuZjBzNCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/zaezT79s3Ng7C/giphy.gif">

Let's go ahead and Create a Docker Volume for Portainer.

___

## Create a Docker Volume for Portainer

A Docker Volume let's containers store things like settings, databases and config files persistently on the host machine independent of the containers lifecycle.

This let's Portainer keep those settings even if the container is destroyed and recreated e.g. if a new Portainer image has been released or the host machine is rebooted.

<img width="100%" style="width:100%" src="https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExMXRod3R4ejQ1emJ5NTJpMThxY3dobHV2MjU3MmY3c3lpa2l3MnAwdCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/1zKRlTFQ278PtPtrV2/giphy.gif">

To create a Docker Volume for Portainer we can use the **Docker Volume** command

![PortainerInstall01](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g9ica96vm9z6qltkwerq.png)

`docker volume create portainer_data`

![PortainerInstall02](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o4h6zngspm67eefhhgha.png)

![PortainerInstall03](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dhakjsjgpgamf9nktqon.png)

Then we can deploy Portainer using the below Docker run command, referencing the "portainer\_data" Docker Volume we've just created

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

![PortainerInstall04](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2lxrim9v04tvwmt31s3k.png)

![PortainerInstall05](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mpe4rsul5cs2rbwlig82.png)

![PortainerInstall06](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2mxtwz2szj5oud98ahl3.png)

![PortainerInstall07](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qaro2q2fldxrzh8wj1k7.png)

Open a browser and connect to the IP address of your Docker installation and port 9000

![PortainerInstall08](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1a9cb8nbcuu81xv3szq7.png)

The admin username will already be filled in for you so go ahead and set up a password this account and make sure you make a note of this too somewhere safe.


![PortainerInstall09a](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xxsrw1wos3h0uulw7ay2.png)

You can untick the Allow collection of anonymous statistics if you don't want to send anything to Portainer

![PortainerInstall09b](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b4xw7hizqkhsa1bnw037.png)

Click **Create user**

This will bring you to the Portainer **Quick Setup Wizard**

![PortainerInstall10](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ie64kfw2he7ux9uhefve.png)

Click **Get Started** to proceed using the local environment Portainer is running in.

![PortainerInstall11](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vz3mixgv0zmo7tbswslw.png)

Click **local** to explore our local Docker environment.

![PortainerInstall14](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8k3hq369w4r0383hqxt8.png)

This will bring us to the **Portainer Dashboard** for our currently running containers, images, volumes, networks and stacks running in Docker.

The current running container, image and volume is **Portainer** itself.

![PortainerInstall15](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dod6ejm4setvuxobbbgl.png)

We're now ready to start using **Portainer** and stacks.

___

## What Are Stacks

Portainer deploys Docker Networks, Containers and Services using a similar set up to Docker Compose YML files using Stacks.

These digital recipe files contain everything needed to start a service like OrganizrV2, a Dashboard for all your self-hosted services or Plex, a self hosted Netflix style Media Server for all your home media.

<img width="100%" style="width:100%" src="https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExeWFxenBtNGpxeXVoejYwOGFzaDluYXdlanN5M28xeHc1NW1mZ21zMiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/10u6gt11vnm812/giphy.gif">

You can then configure the stack to use the settings that you want and even deploy different versions using the same stack by changing a few variables e.g. the config folder and IP address.

We'll focus more on the manual stack setup in another blog article soon, as in this guide we're going to use a more automated way of doing this.

To try this out we're going to install a privacy-focused version of Google called Whoogle on your server using a custom Portainer App Template List.

___

## Add a custom Portainer App Template List

The most powerful feature in Portainer is the large list of curated images that can be added to make trying out new services or applications and then removing them a breeze.

The default list already contains some services to get started.

![Portainer App Template 01](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cvauxsd4nwhznymjsl9p.png)

We're going to add a new custom list that includes a lot more than the inbuilt list from the Github Portainer Templates by Qballjos

[Github Portainer Templates by Qballjos](https://github.com/Qballjos/portainer_templates)

From the **Dashboard** menu on the left we're going to scroll down to the **Settings**

![Portainer App Template 02](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ksqsqhfdlb6oxtkkofuo.png)

There is a **JSON** file already filled in here with the current default list of stacks from Portainer

Paste the below line in there

`[https://raw.githubusercontent.com/Qballjos/portainer_templates/master/Template/template.json]`

![Portainer App Template 03](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bctdaqmy33fah1k6ahcf.png)

Press Save to Apply the settings to your **App Templates**

![Portainer App Template 04](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kqof5b45osc243icrhpg.png)

We've now got a combined and curated list of the most popular and useful self hosted services and applications to choose from, right inside Portainer.

![Whoogle Portainer Install 01](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cx7sfxdps89lbe4ydh78.png)

Think of it as a free Portainer App Store to search for and start up services in a few clicks.

<img width="100%" style="width:100%" src="https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExZW95aDBxYWNkaGlxZDc5cDBsbzdvcHAxcjIzM3IzdzBxZnI2cXJ3aSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/ugOMVsKh9pMWxji7w4/giphy.gif">

___

## Customise and deploy a stack from App Templates

One of the reason's many people choose to self-host is to be able to stop giving their digital data and online habits to online services like Google and Meta.

<img width="100%" style="width:100%" src="https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExOG5ydG1zaHc0YnF2ZXFkN2JoYTkzNTYyd3QwOHc3aHptNjdvempoaSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/Zkf1NYy2aQXs7fQaKP/giphy.gif">

We're going to self host our own search engine using Google but without having to give up our digital privacy using [**Whoogle**](https://whoogle.io/)

![Whoogle Portainer Install 01](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cx7sfxdps89lbe4ydh78.png)

![https://github.com/benbusby/whoogle-search](https://github.com/benbusby/whoogle-search)

Click **App Templates** if you're not already there and scroll down or search for **Whoogle** in the list.

![Whoogle Portainer 01](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j062bvrmpz2ul53d4i84.png)

Click **Whoogle**

![Whoogle Portainer 02](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dfw8pbzm2re6xa462f7q.png)

This will bring you to the **App Template** setup with the default name **whoogle**

![Whoogle Portainer 03](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/261cj7p0pqd6v0h9xbb3.png)

It will also have the network set to **bridge** as default which we'll leave for now

Scroll down and click the **Plus** sign to the left of **Advanced Options**

![Whoogle Portainer 04](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k52vhlbfiulj8c5qu00j.png)

For our **Port mapping**, we'll leave the default **host** port we connect to as **5001** and **container** port of **5000**

For this tutorial, we're going to use the **auto** function for **Volume mapping** instead of the **bind** function to create a local volume on the host automatically

Scroll down to **Actions** and click **Deploy the container** to go ahead and start up our service

![Whoogle Portainer 06](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dmmkl7qa2nfz28kkknct.png)

You'll be brought back to the **Containers** Page with your new service getting ready to start.

![Whoogle Portainer 07](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/elnm7rwgsud7sxqyon8w.png)

Refresh the Page and you should see the State should turn green and show as **running** or in our case **healthy**

![Whoogle Portainer 11](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a6cf6gd74zwy8bl7c8ws.png)

Open a new tab in your browser and go to your Server IP address and port 5001

For our example it's the below

`https://192.168.0.23:5001`

This will bring you to the **Whoogle** home page which is hosted on your server.

![Whoogle Portainer 12](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z7hbaa58qgiehxyriud2.png)

Check out the configuration options for some really interesting ways to search.

![Whoogle Portainer 13](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7k9nwtp7udcluaa9khsz.png)

Or just do your first search without giving Google your browsing data along the way

![Whoogle Portainer 14](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lkws0mvnb561mp5gyecd.png)

![Whoogle Portainer 15](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9g1uxz0boeg3ch1w08et.png)

Congratulations, you've deployed your first self hosted service in a container using **Portainer**.

You can deploy almost everyone of those services on the list using this same method so get exploring and try out some of those complicated services you always wanted to without all the hassle.

Next up we're going to start getting fancy by forwarding custom hostnames using Nginx Proxy Manager and Pi-Hole's Local DNS feature.

<img width="100%" style="width:100%" src="https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExOXFuZzl4NWd0MzlqbWE4azRudnV2ZTRveTBqdnpxOG9yajhnODh0biZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/26Ff29tMYBOScmQEM/giphy.gif">

___

For more Docker Compose files check out **ReproDev Recipes** on GitHub with Docker Compose files for you to try out

[GitHub - reprodev/reprodev-recipes: ReproDev Recipes is a repository of code snippets and docker compose files from reprodev.com](https://github.com/reprodev/reprodev-recipes/tree/main)

___

Check out the guide below if you want more information on What Docker is and how to get started

[Get Started with Docker - Part 1 : An Intro to Docker](https://dev.to/reprodev/get-started-with-docker-part-1-an-intro-to-docker-3b81)

___

Don't forget to explore the rest of our website as we build out more content. Stay tuned for more tutorials, tips, and tricks to help you make tech work for you.

If you want to stay up-to-date with regular updates, make sure to subscribe to our free mailing list.

___