Easy Steps To Set up Portainer on Ubuntu 22.04 – OrcaCore
This guide intends to teach you to Set up Portainer on Ubuntu 22.04. Portainer is a universal container management tool that can work with both Docker and Kubernetes to make the deployment and management of containerized applications and services easier and more efficient. Setting up Portainer on Ubuntu 22.04 simplifies container orchestration, providing a user-friendly interface for managing your applications. This detailed guide will walk you through the process, step-by-step.
Now follow the guide steps below on the Orcacore website to start your Portainer setup on Ubuntu 22.04.
To install Portainer, you need some requirements, then, follow the rest of the article to complete this guide.
Requirements for Portainer Setup
You must log in to your server as a root or non-root user with sudo privileges. To do this, you can follow this guide on Initial Server Setup with Ubuntu 22.04.
Then, you must have Docker installed on your server. To do this, you can follow our guide on Install and Use Docker on Ubuntu 22.04.
Also, you must have Docker Compose installed on your server. For this purpose, you can visit this guide on Install and Use Docker Compose on Ubuntu 22.04.
Install Portainer on Ubuntu 22.04
At this point, you can start to install Portainer container management on your server.
Create Docker Volume For Portainer
First, you need to create a volume to store Portainer data. Docker volumes are file systems mounted on Docker containers to preserve data generated by the running container. To do this, run the command below:
docker volume create data
Then, verify it by using the command below:
docker volume ls
**Output**
DRIVER VOLUME NAME
local data
Download and Run Portainer Docker Image
Now you can use the following command to download and run the Portainer docker image:
docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v data:/data portainer/portainer
**Output**
latest: Pulling from portainer/portainer
772227786281: Pull complete
96fd13befc87: Pull complete
0bad1d247b5b: Pull complete
b5d1b01b1d39: Pull complete
Digest: sha256:47b064434edf437badf7337e516e07f64477485c8ecc663ddabbe824b20c672d
Status: Downloaded newer image for portainer/portainer:latest
93c8190fe97d1ae952bbabddb98cb2eebcbd7bd476fadb9781745c800c9108ee
Next, check your Portainer status with the following command:
docker ps
**Output**
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
93c8190fe97d portainer/portainer "/portainer" About a minute ago Up Abou t a minute 0.0.0.0:8000->8000/tcp, :::8000->8000/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp, 9443/tcp portainer
Access Portainer Dashboard on Ubuntu 22.04
At this point, your Portainer is running on port 9000. You can access it through the web interface by typing your server’s IP address in your web browser followed by 9000:
http://your-server-ip:9000
In the first screen, you should create the initial administrator user.

Then, you will see your Portainer dashboard.

You can now easily host your application on the containerization platform via a web-based interface. For more information check the official website.
Conclusion
At this point, you have earned to Set up the Portainer Container Management Tool on Ubuntu 22.04. With Portainer you can easily manage your containers via a graphical interface. Setting up Portainer on Ubuntu 22.04 is a key step in streamlining your container management workflow.
Hope you enjoy it. You may also interested in these articles:
Install GitHub Desktop on Ubuntu 22.04
Install and Use Flatpak on Ubuntu 22.04
Set up Postfix Mail Server on Ubuntu 20.04
FAQs
What is the Portainer running port?
Portainer uses port 9000.
How do I access the Portainer web interface?
You can navigate to the following URL to access the Portainer dashboard: http://server-ip:9000
Can I use Portainer to manage Kubernetes?
Yes, Portainer can be used to manage Kubernetes clusters.
Alternative Solutions for Deploying Portainer on Ubuntu 22.04
While the above method effectively deploys Portainer using a single docker run
command, there are alternative approaches that provide more flexibility and maintainability, especially in production environments. Here are two such alternatives: using Docker Compose and using a Kubernetes deployment. These approaches also allow for more complex configurations and integrations.
1. Deploying Portainer with Docker Compose
Docker Compose offers a declarative way to define and manage multi-container Docker applications. It uses a YAML file to configure the application’s services, networks, and volumes. Using Docker Compose for Portainer provides several advantages, including:
- Version Control: The configuration is stored in a file that can be version-controlled.
- Reproducibility: The same configuration can be easily deployed across different environments.
- Simplified Management: All services defined in the Compose file can be managed with a single command.
Here’s how you can deploy Portainer using Docker Compose:
-
Create a
docker-compose.yml
file:version: "3.9" services: portainer: image: portainer/portainer-ce:latest container_name: portainer restart: always ports: - "8000:8000" - "9000:9000" volumes: - /var/run/docker.sock:/var/run/docker.sock - portainer_data:/data volumes: portainer_data:
Explanation:
version: "3.9"
: Specifies the version of the Docker Compose file format.services
: Defines the services that make up the application. In this case, it’s just theportainer
service.image: portainer/portainer-ce:latest
: Specifies the Docker image to use for the Portainer service. Thece
tag specifies the community edition.container_name: portainer
: Sets the name of the container.restart: always
: Configures Docker to automatically restart the container if it fails.ports
: Maps the ports on the host to the ports inside the container.volumes
: Mounts the Docker socket and creates a named volume for Portainer data persistence. Using a named volume likeportainer_data
is preferable to a bind mount, as Docker manages the volume’s location.
-
Deploy Portainer:
Navigate to the directory containing the
docker-compose.yml
file and run the following command:docker-compose up -d
This command will download the Portainer image (if it’s not already present) and start the Portainer container in detached mode (
-d
). -
Verify the Deployment:
You can verify that Portainer is running using the
docker ps
command:docker ps
This will show the running Portainer container. You can then access the Portainer web interface at
http://your-server-ip:9000
.
2. Deploying Portainer with Kubernetes
For organizations already using Kubernetes, deploying Portainer within the cluster provides centralized management of both Docker and Kubernetes environments. This approach offers scalability, high availability, and integration with existing Kubernetes infrastructure.
Here’s how to deploy Portainer using Kubernetes:
-
Create a Kubernetes Deployment and Service:
You’ll need to create a YAML file (e.g.,
portainer-k8s.yaml
) that defines the Kubernetes Deployment and Service for Portainer.apiVersion: apps/v1 kind: Deployment metadata: name: portainer spec: replicas: 1 selector: matchLabels: app: portainer template: metadata: labels: app: portainer spec: containers: - name: portainer image: portainer/portainer-ce:latest ports: - containerPort: 9000 name: webui - containerPort: 8000 name: tunnel volumeMounts: - mountPath: /data name: portainer-data - mountPath: /var/run/docker.sock name: docker-socket volumes: - name: portainer-data persistentVolumeClaim: claimName: portainer-pvc - name: docker-socket hostPath: path: /var/run/docker.sock type: Socket --- apiVersion: v1 kind: Service metadata: name: portainer spec: type: NodePort # Or LoadBalancer if using a cloud provider selector: app: portainer ports: - port: 9000 targetPort: 9000 nodePort: 30001 # Choose an available port on your nodes (30000-32767) --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: portainer-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Gi # Adjust size as needed
Explanation:
- Deployment: Defines how Portainer should be deployed in the cluster, including the number of replicas, the container image, and port mappings. A
hostPath
volume is used to expose the docker socket of the underlying Kubernetes node to the Portainer container. This allows Portainer to manage the Docker daemon on that node. ApersistentVolumeClaim
(PVC) is defined to request persistent storage for Portainer’s data. - Service: Exposes Portainer to the outside world. In this example, a
NodePort
service is used, which makes Portainer accessible on each node’s IP address at the specifiednodePort
(e.g.,http://node-ip:30001
). Consider using aLoadBalancer
service type if you’re deploying to a cloud provider like AWS, Azure, or GCP for automatic load balancing and external IP assignment. - PersistentVolumeClaim: Requests a PersistentVolume of 10Gi to store Portainer data. The
ReadWriteOnce
access mode means the volume can only be mounted by a single node at a time. This is generally suitable for Portainer. The cluster administrator needs to ensure that a PersistentVolume (PV) matching the claim is available, either dynamically provisioned or pre-created.
- Deployment: Defines how Portainer should be deployed in the cluster, including the number of replicas, the container image, and port mappings. A
-
Apply the Configuration:
Deploy the configuration to your Kubernetes cluster using the
kubectl apply
command:kubectl apply -f portainer-k8s.yaml
-
Access Portainer:
Once the deployment and service are running, access Portainer through the
NodePort
service athttp://node-ip:30001
or through the external IP if you used aLoadBalancer
service. Replacenode-ip
with the IP address of any of your Kubernetes worker nodes.
These alternative methods, using Docker Compose and Kubernetes, offer more robust and scalable solutions for deploying Portainer on Ubuntu 22.04, especially in production environments. They provide better version control, reproducibility, and integration with existing infrastructure.