Build a free open source and easy-to-use Docker panel Portainer

Portainer is an easy-to-use Docker container control panel. Its code repository is here . It supports single-node and cluster deployments.

Before this, I had fully containerized my personal server. If you can visually operate and monitor various containers, it will be of great help to daily operation and maintenance, and you will feel that everything is under control.

You can see the effect after building, the interface is still very beautiful.

You can quickly pull the mirror image

You can visualize the release container, and flexibly set parameters such as environment variables, network, and restart policies.

When the image is updated, the container can be quickly updated with the new image.

You can also quickly enter the access container command line and view container logs.

It can be said that the functions I need every day have all the functions, and I feel very complete.

to build

So for a single-point server, how to build it, first of all, you need to confirm that your server currently has Docker installed.

can enterdocker -v Let’s see if docker exists in the current environment.

If it does not exist, you need to install docker, you can find a tutorial on Google. For EC2 on AWS, you can entersudo yum install docker -y to install.

After confirming that Docker is installed. Check if Docker is started. Then check if there is a docker.sock file in the /var/run path.

Then, confirm that port 8000 and port 9443 are not occupied, because Portainer will use these two ports later.

Store application data in Docker Volume

If you want to store the application data generated by Portainer in a Docker Volume, you can directly execute the following command. After the subsequent deployment is completed, the Docker Volume used by Portainer can also be seen and managed in Portainer. If port 8000 is occupied, you can use-p 8000:8000 Change to another port, similar to-p 12345:8000 . Port 9443 is similar.

If you want to specify another name for the container, you can modify the –name parameter, for example--name myportainer .

% docker volume create portainer_data 
% 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

 

Map application data to other places on the host

You can create a directory portainer under /data, so the final path is /data/portainer. I finally chose this way, because I purchased the AWS data disk separately to store the application data of my server. So I tend to store application data in the data disk.

Other parameter settings are consistent with the above part.

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

 

Confirm deployment status

then executedocker ps To confirm whether Portainer starts normally. You can refer to the information in the red box in my screenshot.

If you wait for a few minutes and see the Status is Up xxx minutes, it means that the Portainer container has been successfully started.

You can then access the panel at https://localhost:9443 and set an admin password.