Installing Portainer

Docker Portainer Installation

Portainer is deployed as a lightweight Docker container on any Linux system running Docker. The main component of Portainer is Portainer Server, which is used to manage containers, networks, and environments. Portainer Agent is the component installed on another Docker system to enable communication with the server.

Follow the steps below to install Portainer and deploy a containerized app to test the installation.

Step 1: Create Docker Volume

Portainer stores information on a Docker volume. Type the following command to create a Docker volume for the Portainer Server:

docker volume create portainer_data

If the operation is successful, the system outputs the name of the volume.

https://phoenixnap.com/kb/wp-content/uploads/2022/05/output-from-docker-volume-create-portainer-data-install-portainer.png

Step 2: Install Portainer Server

The latest Portainer Community Edition image is available on Docker Hub. Use the docker run command to pull the image and start a Portainer Server container:

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

Portainer exposes the UI via the secure port 9443. Port 8000 is used for edge computing and is optional unless you are planning to use edge agents.

https://phoenixnap.com/kb/wp-content/uploads/2022/05/output-from-docker-run-d-p-8000-8000-p-9443-9443-name-portainer-install-portainer.png

Note: BMC offers affordable instances that satisfy all the performance requirements for edge computing.

docker run pulls the necessary images and starts the container. Check that Portainer is running by typing:

docker ps

The command lists all the running containers. Find the container named portainer and make sure its status is Up.

https://phoenixnap.com/kb/wp-content/uploads/2022/05/output-from-docker-ps-install-portainer.png

Step 3: Access Portainer Dashboard

Portainer has a web UI accessible through an internet browser. To access the main Portainer dashboard:

  1. In a browser, visit the following address:
https://localhost:9443

Note: If you receive a blank page with the Client sent an HTTP request to an HTTPS server message, make to explicitly state HTTPS as the connection type.

  1. The first time you access Portainer, the system asks to create a password for the admin user. Type the password twice and select the Create user button.

https://phoenixnap.com/kb/wp-content/uploads/2022/05/creating-admin-user-new-portainer-installation.png

The Environment Wizard starts.

  1. Select the Get Started button to go to the dashboard and start using Portainer in the local environment only. To add other environments during the initial setup, click Add Environments.

https://phoenixnap.com/kb/wp-content/uploads/2022/05/quick-setup-environment-wizard-install-portainer-pnap-bmc.png

Note: You can add environments later from the Portainer dashboard.

Step 4 (Optional): Add More Environments to Portainer Installation

You can manage multiple Docker environments within the Portainer UI. Moreover, each environment needs to have a Portainer Agent instance installed. The agent then uses port 9001 to communicate with the server.

Follow the steps below to add an environment to Portainer.

  1. Type the following command to start a Portainer Agent container on the system you want to add:
docker run -d -p 9001:9001 --name portainer_agent --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/volumes:/var/lib/docker/volumes portainer/agent:2.9.3

Wait for Docker to pull the necessary images and initiate the container.

https://phoenixnap.com/kb/wp-content/uploads/2022/05/output-from-docker-run-d-p-9001-9001-name-portainer-agent-etc.png

  1. To register the new environment in Portainer, you need the IP address of the system hosting the environment. If you do not know the IP, use the ip command to obtain it:
ip a

The command lists the network interfaces on your system. Make a note of the main interface's IP address.

https://phoenixnap.com/kb/wp-content/uploads/2022/05/output-from-ip-a-install-portainer.png

Return to the Portainer Server UI.

  1. Select Environments in the menu on the left side and click Add environment.

https://phoenixnap.com/kb/wp-content/uploads/2022/05/adding-new-environment-in-portainer-server.png

Note: If you select the Add Environments button in Step 3, Portainer takes you directly to the Create Environment page.

On the Create Environment page, fill in the details about the environment you want to add.

  1. Write the name of the environment in the Name field

  2. Type the URL of the system running Portainer Agent in the Environment URL field.

[ip-address]:9001
  1. When you finish the setup, select the Add environment button in the Actions section.

https://phoenixnap.com/kb/wp-content/uploads/2022/05/creating-new-environment-in-portainer-server.png

The new environment appears on the Environments page.

https://phoenixnap.com/kb/wp-content/uploads/2022/05/new-environment-in-portainer-server-install-portainer.png

Step 5: Deploy Container Using Portainer

Test your Portainer setup by deploying a test Docker container. Follow the steps below to install an Apache HTTP Server instance.

  1. Select Containers in the menu on the left side to open the Containers page.

https://phoenixnap.com/kb/wp-content/uploads/2022/05/accessing-containers-section-install-portainer.png

  1. Click the Add container button in the action bar.

https://phoenixnap.com/kb/wp-content/uploads/2022/05/adding-new-container-portainer-dashboard-install-portainer.png

  1. Provide details for the container you want to run, including the container name, the image name, and the connection ports.

https://phoenixnap.com/kb/wp-content/uploads/2022/05/creating-test-httpd-container-in-portainer-install-portainer.png

  1. When you finish setting up the container, scroll to the bottom of the page and select the Deploy the container button.

https://phoenixnap.com/kb/wp-content/uploads/2022/05/deploying-the-container-in-portainer-install-portainer.png

Wait for Portainer to deploy the container. When the container is ready, its state will be running.

https://phoenixnap.com/kb/wp-content/uploads/2022/05/httpd-latest-container-on-container-list-install-portainer.png

  1. Open another browser tab and type the IP address of your environment followed by the port assigned to the container. The Apache server shows the confirmation message.

https://phoenixnap.com/kb/wp-content/uploads/2022/05/confirming-success-httpd-deployment-install-portainer.png