Docker | Detailed steps to install portainer with docker

portainer is a visual interface for container management. Those who do not want to use commands to manage containers in the virtual environment can choose to install portainer to manage containers. It is very convenient to view logs, start and stop containers, etc.

1. Search portainer mirror

docker search portainer

2. Pull the portainer image

docker pull portainer/portainer-ce


3. Start the portainer container
# Start the image

# 启动镜像
docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v /dockerData/portainer:/data --restart=always --name portainer portainer/portainer-ce:latest

- p: Specify the host port and container port. The portainer default port is 9000

- v: Directory mapping, mapping /var/run/docker.sock to the container, used to access the Docker daemon process and control Docker. /dockerData/portainer saves Portainer configuration information.

–restart=always: means to always restart the container when the container exits, and there are several other restart strategies: no, on-failure, on-failuer:n, unless-stopped

-p 1126:9000 port mapping defaults to 9000, mapping is 1126
- portainer image name

(if wrong [PS1])


4. docker ps view container

-p 9000:9000 port mapping default is 9000, mapped to 9000
portainer/portainer mirror name

# View log 

docker logs -f portainer

(wode hezhide mingcheng shi portaine)

5. After the startup is completed, visit http://ip:9000

For the first login, you need to create a password for the administrator admin, and log in after setting

For the first time, the installation interface will pop up, configure the account password, and choose whether it is a local Docker or a remote Docker. Generally, we choose a local Docker, that is, local. You can view the configuration information of the host machine, and view related information such as containers, mirrors, networks, and volumes.

 Click on the entry on the left to see the visual interface of our remote server or local docker container~

 

 If an error message appears after entering the webpage, please refer to [PS2] [PS3].

Problems and solutions [Problem and Slove]

[PS1] 

问题:docker: Error response from daemon: driver failed programming external connectivity on endpoint portainerv1 (3d831aa6e5bb0b69a9e4c5cfe193570d757a5ee93998dd362fdaf4ed3f6b259e): Bind for 0.0.0.0:9000 failed: port is already allocated.

docker: Error response from daemon: Driver programming failed for external connection at endpoint portainerv1 (3d831aa6e5bb0b69a9e4c5cfe193570d757a5ee93998dd362fdaf4ed3f6b259e). Binding 0.0.0.0:9000 failed: Port already assigned.

docker: Error response from daemon: Conflict. The container name "/portainerv1" is already in use by container "c0f5e58adf90ee1484cb259ab89caac0806c148be16c5f930bb3b6f7ac4c8007
" . use. Delete (or rename) the container before it can be reused.

 [PS2]

that is

Cause analysis : The port number is occupied and needs to be reallocated.

 [PS3] Install Portainer on Linux using Docker

Portainer consists of two elements, the Portainer server and the Portainer Agent . Both elements run as lightweight Docker containers on the Docker engine. This document will help you install the Portainer Server container in a Linux environment. To add a new Linux environment to an existing Portainer server installation

By default, the Portainer server will 9443expose the UI through port , and 8000the TCP tunnel server through port . The latter is optional and only required if you plan to use edge computing capabilities with edge proxies.

First, create the volume that Portainer Server will use to store its database:

docker volume create portainer_data

download and install the 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-ee:latest

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

By default, Portainer generates and uses a self-signed SSL certificate to secure ports 9443. Alternatively, you can provide your own SSL certificate during installation or after installation is complete through the Portainer UI .

Portainer Server is now installed. You can check whether the Portainer Server container is started by running docker ps:

Now that the installation is complete, you can log in to the Portainer Server instance by opening a web browser and going to:

https://localhost:9443

本地主机Replace with the relevant IP address or FQDN if necessary , and adjust the port if it was changed previously.

You will see the Portainer Server initial setup page.


references

【1】Install Portainer - Portainer Documentation 

Guess you like

Origin blog.csdn.net/weixin_44649780/article/details/128401975