Managing containers can be challenging, especially when dealing with multiple instances or complex configurations. Portainer simplifies this process by providing an intuitive web-based interface for Docker and Kubernetes environments. If you’re a developer just starting with containers, Portainer makes it easy to visualize, deploy, and manage your containerized applications efficiently. With support for a wide range of platforms, it’s a go-to tool for streamlining container management.
In this guide, we’ll walk you through the steps to set up Portainer on Ubuntu, allowing you to manage containers with an easy-to-use Web UI.
Prerequisites
- A Virtual Machine (such as the ones provided by NodeShift) with at least:
- 1 vCPUs
- 1 GB RAM
- 10 GB SSD
- Ubuntu 22.04 VM
Note: The prerequisites for this are highly variable across use cases. A high-end configuration could be used for a large-scale deployment.
Step-by-step process to set up Portainer on Ubuntu
For this tutorial, we’ll use a CPU-powered Virtual Machine by NodeShift, which provides high-compute Virtual Machines at a very affordable cost on a scale that meets GDPR, SOC2, and ISO27001 requirements. It also offers an intuitive and user-friendly interface, making it easier for beginners to get started with Cloud deployments. However, feel free to use any cloud provider you choose and follow the same steps for the rest of the tutorial.
Step 1: Setting up a NodeShift Account
Visit app.nodeshift.com and create an account by filling in basic details, or continue signing up with your Google/GitHub account.
If you already have an account, login straight to your dashboard.
Step 2: Create a Compute Node (CPU Virtual Machine)
After accessing your account, you should see a dashboard (see image), now:
- Navigate to the menu on the left side.
- Click on the Compute Nodes option.
- Click on Start to start creating your very first compute node.
These Compute nodes are CPU-powered virtual machines by NodeShift. These nodes are highly customizable and let you control different environmental configurations, such as vCPUs, RAM, and storage, according to your needs.
Step 3: Select configuration for VM
- The first option you see is the Reliability dropdown. This option lets you choose the uptime guarantee level you seek for your VM (e.g., 99.9%).
- Next, select a geographical region from the Region dropdown where you want to launch your VM (e.g., United States).
- Most importantly, select the correct specifications for your VM according to your workload requirements by sliding the bars for each option.
Step 4: Choose VM Configuration and Image
- After selecting your required configuration options, you’ll see the available VMs in your region and as per (or very close to) your configuration. In our case, we’ll choose a ‘1 vCPUs/1GB/25GB SSD’ Compute node.
- Next, you’ll need to choose an image for your Virtual Machine. For the scope of this tutorial, we’ll select Ubuntu.
Step 5: Choose the Billing cycle and Authentication Method
- Two billing cycle options are available: Hourly, ideal for short-term usage, offering pay-as-you-go flexibility, and Monthly for long-term projects with a consistent usage rate and potentially lower cost.
- Next, you’ll need to select an authentication method. Two methods are available: Password and SSH Key. We recommend using SSH keys, as they are a more secure option. To create one, head over to our official documentation.
Step 6: Finalize Details and Create Deployment
Finally, you can also add a VPC (Virtual Private Cloud), which provides an isolated section to launch your cloud resources (Virtual machine, storage, etc.) in a secure, private environment. We’re keeping this option as the default for now, but feel free to create a VPC according to your needs.
Also, you can deploy multiple nodes at once using the Quantity option.
That’s it! You are now ready to deploy the node. Finalize the configuration summary; if it looks good, go ahead and click Create to deploy the node.
Step 7: Connect to active Compute Node using SSH
As soon as you create the node, it will be deployed in a few seconds or a minute. Once deployed, you will see a status Running in green, meaning that our Compute node is ready to use!
Once your node shows this status, follow the below steps to connect to the running VM via SSH:
- Open your terminal and run the below SSH command:
(replace root
with your username and paste the IP of your VM in place of ip
after copying it from the dashboard)
ssh root@ip
2. In some cases, your terminal may take your consent before connecting. Enter ‘yes’.
3. A prompt will request a password. Type the SSH password, and you should be connected.
Output:
Step 8: Install Docker as dependency
- Start by updating the package source-list to fetch the latest versions.
sudo apt update
Output:
2. Install Docker
Next, before installing Portainer, we’ll need to install Docker from Ubuntu package repositories. Use the below apt
command to do so.
sudo apt install docker.io -y
Output:
3. Confirm and start Docker.
Once the installation is done, check the status of Docker to confirm it is running correctly.
sudo systemctl status docker
Output:
Further, start the Docker system.
sudo systemctl start docker
Finally, add the currently logged-in user to Docker group to give access to Docker commands.
sudo usermod -aG start docker
Step 9: Run Portainer docker container
To install Portainer and start using it, we’ll simply pull its image from the Docker hub and run the container, and we can start using it.
- Pull Portainer’s docker image.
docker pull portainer/portainer-ce:latest
Output:
2. Confirm the image.
docker images
Output:
3. Run Portainer’s Docker container.
docker run -d -p 9000:9000 --restart always -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer-ce:latest
4. Confirm if the container is running.
docker ps
Output:
Step 10: Access the Portainer Web UI
Once the container is up and running, open a browser and paste the following URL to access your Portainer web instance.
(replace <YOUR_SERVER_IP>
with your server’s IP address)
http://<YOUR_SERVER_IP>:9000
The web interface looks like this:
Enter a unique username and strong password to create a user.
Note: In some cases, as you hit the “Create user” button, you may encounter an error like this:
Which essentially says that your server has been timed out. To fix this, you will need to stop and restart your Docker container using the following commands:
docker stop <CONTAINER_ID>
docker start <CONTAINER_ID>
After this, enter your credentials once again and create a user. It should work fine this time.
Step 11: Deploy a container using Portainer
With the Portainer Web UI, you can easily deploy Docker containers, just like you would using Docker commands, but with an intuitive dashboard.
- After you’ve successfully logged in, click on Get Started to start using the dashboard.
2. Click Live connect to connect your local docker environment with Portainer.
3. Select Containers to start creating containers.
4. Add a new container by clicking on Add container.
5. Give a name to your container, and enter the image you want to pull.
For example, we will deploy a MongoDB container using the “mongodb:7.0.16-jammy” image from the Docker Hub. You can search for the full name of your preferred image on the Docker Hub.
6. Click on Deploy the container.
In just a few seconds or a minute, your newly deployed container will appear on the container list with the status running
.
You can also run the docker ps
command in your server terminal to double-check the container’s status.
Conclusion
Setting up Portainer on Ubuntu helps developers and teams to manage containers efficiently through a user-friendly web UI, simplifying complex operations and enhancing productivity. By leveraging Portainer, you can streamline your container management processes, regardless of your experience level. NodeShift helps in enabling such seamless container experiences, providing tools and expertise to help you deploy and scale containerized applications effortlessly. Whether you’re managing single instances or large-scale deployments, NodeShift ensures you have the right compute to make container orchestration simple yet powerful.