DEV Community

Cover image for Get Started with Docker - Part 4: Portainer : How To Deploy Containers The Easy Way
Repro Dev
Repro Dev

Posted on • Edited on • Originally published at reprodev.com

Get Started with Docker - Part 4: Portainer : How To Deploy Containers The Easy Way

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.

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


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

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

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.

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

PortainerInstall01

docker volume create portainer_data

PortainerInstall02

PortainerInstall03

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

PortainerInstall05

PortainerInstall06

PortainerInstall07

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

PortainerInstall08

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

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

PortainerInstall09b

Click Create user

This will bring you to the Portainer Quick Setup Wizard

PortainerInstall10

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

PortainerInstall11

Click local to explore our local Docker environment.

PortainerInstall14

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

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.

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

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

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

Portainer App Template 02

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

Press Save to Apply the settings to your App Templates

Portainer App Template 04

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

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


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.

We're going to self host our own search engine using Google but without having to give up our digital privacy using Whoogle

Whoogle Portainer Install 01

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

Click Whoogle

Whoogle Portainer 02

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

Whoogle Portainer 03

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

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

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

Whoogle Portainer 07

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

Whoogle Portainer 11

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

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

Whoogle Portainer 13

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

Whoogle Portainer 14

Whoogle Portainer 15

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.


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


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


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.


Top comments (1)

Collapse
 
zaeidiu profile image
Info Comment hidden by post author - thread only accessible via permalink
Zaeid Hasan

Artificial Intelligence (AI)

Image description

Artificial Intelligence (AI) refers to the development of computer systems that can perform tasks that typically require human intelligence. These tasks include learning, reasoning, problem-solving, perception, understanding natural language, and even interacting with the environment. AI systems are designed to mimic cognitive functions that humans associate with other human minds, such as "learning" and "problem-solving".

There are several approaches to AI, including:

  1. Machine Learning: This involves training a model with data to recognize patterns and make predictions or decisions without being explicitly programmed. Types of machine learning include supervised learning, unsupervised learning, and reinforcement learning.

  2. Deep Learning: A subset of machine learning, deep learning involves using neural networks with many layers (hence "deep") to learn representations of data. Deep learning has been particularly successful in tasks like image and speech recognition.

  3. Natural Language Processing (NLP): NLP focuses on enabling computers to understand, interpret, and generate human language in a way that is both useful and meaningful. This is crucial for applications like chatbots, translation services, and sentiment analysis.

  4. Computer Vision: Computer vision enables computers to interpret and understand the visual world through digital images or videos. This is essential for applications such as object recognition, facial recognition, and autonomous vehicles.

AI has a wide range of applications across various industries, including healthcare, finance, transportation, entertainment, and more. Its potential to automate tasks, provide insights from large datasets, and augment human capabilities makes it a rapidly growing field with significant societal impacts. However, there are also concerns related to ethics, bias, privacy, and job displacement that come with the widespread adoption of AI technologies.

Read more ..............

Some comments have been hidden by the post's author - find out more