Lets say you’re running docker containers on the host machine and you want to manage them.
And also you want to manage docker images , volumes , stopping , starting and restarting containers , making deployments etc , Which are currently handled using docker command line.For which We should have docker commands in place.
But In this tutorial , We will see how to manage all the docker resources using Portainer.
What is Portainer?
Portainer a lightweight web based tool which runs as a docker container on the Docker host.
Portainer is used to manage docker containers , images , deployments from the web browser graphically.
With Portainer , We can manage either Local or Remote Docker hosts.
Once you have docker installed on the system , We can go ahead and run the portainer as the docker container.
First We need to create a Docker volume ,
docker volume create portainer_data
portainer_data is the volume created for portainer. The volume is created to store the data of portainer.
To list the docker volumes,
docker volume ls
Next step is to pull the docker image of the portainer to the local system and run it.
Using the below command , We can run the portainer container and we can access it on port 9000,
sudo docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
It pulls the image and mount the socket on the host inside the docker container.So that the portainer container can connect with docker daemon directly and manage it.
Run the below command to list the docker containers,
To access the Web UI of the portainer , We need to check the IP address of the Docker host machine,
and then we can access it as shown below.
You will see the following page , Where you will be asked to setup a password.
Provide a password with the minimum of 8 characters.
and click Create user
You should see the following page.
Depending on whether you’re running Docker environment on Local or Remote host , Select and click Connect
In the Home page , You will get the host and the resources running on that environment.
Click that and you will be able to check all the resources such as container , volumes , stacks , images , networks etc.
Now you can start managing the environment using this UI.
In the navigation pane , You can find various options , Lets check one by one.
Click App Templates , Which will list all the available docker images from the Docker registry using that we can deploy the containers.
For example , If you want to deploy Nginx into the Local environment , Click Nginx , Provide a name for the Container and then click Deploy the container.
As soon as the container is deployed , You will be directed to the container page , Where you can check all the containers.
We can manage the container from here , We can start , stop , kill , restart , pause , resume and remove the containers.
Also We can add containers from this page , By clicking Add container
Provide a container name and Registry be DockerHub and for Image , Start typing the image name , It will fetch and list the image automatically.
and click Deploy the container
From this page , We can check the logs of a container , inspect it , monitor and ssh into it.
Click the first icon to check the logs of the containers.
The second icon is to inspect the container.
Third icon is to check the resource usage such as CPU , Memory and Network by the containers and to monitor them.
and the fourth icon is to SSH into the container.
Click Images , Here we can manage the docker images in the host.
To pull image from DockerHub to local system , Enter the image name with or without tag and then click Pull the image
You can find the lists of images here.
To check the Dockerfile of an image , Click the Image Id , Check Image layers.
You can find the networks and volumes used by the containers.
In the Volumes page , We can Create or Remove Volumes.
In the Events page , We can check all the docker events.
From the Host page , We can find the details about the Docker host.
We have learnt to manage the Docker environment using Portainer.
Thanks for reading this article.
Please do check out my other articles.