Build a free open source good Docker panel Portainer

Portainer is a good control panel for Docker containers. Its code repository is here. It supports single node and cluster deployments.

Prior to this, I had completely containerized my personal server. If you can visualize the operation and monitoring of various containers, it helps a lot in daily operation and maintenance, and you 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 visually publish containers and flexibly set environment variables, network, restart policy and other parameters.

You can quickly update containers with new mirrors when they are updated.

It is also possible to quickly access the Access Container command line and view container logs.

Suffice it to say, I have all the features I need on a daily basis, and it feels complete.

Build

So how to build for a single point server, first you need to make sure your server currently has Docker installed.

You can type docker -v to see if docker exists in your current environment.

If it doesn’t exist and you need to install docker, you can look for tutorials on Google. For EC2 on AWS, you can type sudo yum install docker -y to install it.

After confirming that Docker is installed. Confirm that Docker is started. Then see if there is a docker.sock file under the /var/run path.

Then, make sure that both port 8000 and port 9443 are not occupied, as Portainer will use them later.

Storing Application Data in Docker Volume

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

If you want to specify the container name as something else, 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

Mapping application data to other places on the host machine

You can create the directory portainer under /data, so that means the final path is /data/portainer.I ended up going this way because I purchased AWS data disks separately to store the application data for my server. So I tend to keep all the application data in the data disk.

The other parameter settings are the same as in the section above.

% 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

Confirming the deployment status

Then run docker ps to confirm that Portainer is starting properly. You can refer to the information in the red box in my screenshot.

If you wait for a few minutes and see Status as Up xxx minutes, the Portainer container has started successfully.

You can then visit https://localhost:9443 to access the panel and set the administrator password.