Docker installation

Introduction to the

For example, in tar -xvf {docker}. TGZ, the variable docker is the specific file name. In this article, Portainer is used to build the clusterCopy the code

Portainer website

Online installation

Official document

Centos,Unbantu and other platforms have slightly different installation methodsCopy the code

Offline installation

Download the docker

Choose the appropriate version to downloadCopy the code
  • unzip
tar -xvf {docker}.tgz
Copy the code
  • Move files
cp docker/* /usr/bin/
Copy the code
  • The registration service
vi /etc/systemd/system/docker.service
Copy the code
  • Configure the service and add the following contents to the docker.service to save

If permission denied occurs, check whether you have permission for the directory

Need to pay attention to parameter ExecStart = / usr/bin/dockerd -h TCP: / / 0.0.0.0:2375 - H Unix: / / var/run/docker. The sock

TCP connection is enabled and the data volume is /var/run/docker. Sock The active management node does not need to enable TCP

  • Docker. Service file
[Unit] Description=Docker Application Container Engine Documentation=https://docs.docker.com After=network-online.target  firewalld.service Wants=network-online.target [Service] Type=notify # the default is not to use systemd for cgroups because the delegate issues still # exists and systemd currently does not support the cgroup feature set required # for Containers run by docker ExecStart = / usr/bin/dockerd -h TCP: / / 0.0.0.0:2375 - H Unix: / / var/run/docker. The sock ExecReload=/bin/kill -s HUP $MAINPID # Having non-zero Limit*s causes performance problems due to accounting overhead # in the kernel. We recommend using cgroups to do container-local accounting. LimitNOFILE=infinity LimitNPROC=infinity LimitCORE=infinity # Uncomment TasksMax if your systemd version supports it. # Only systemd 226 and above support this version. #TasksMax=infinity TimeoutStartSec=0 # set delegate yes so that systemd does not reset the cgroups of docker containers Delegate=yes # kill only the docker process, not all processes in the cgroup KillMode=process # restart the docker process if it exits prematurely Restart=on-failure  StartLimitBurst=3 StartLimitInterval=60s [Install] WantedBy=multi-user.targetCopy the code
  • Adding Directory Permission
chmod +x /etc/systemd/system/docker.service
Copy the code
  • reload
systemctl daemon-reload
Copy the code
  • Start the docker
systemctl start docker 
Copy the code
  • Verify docker startup status
systemctl status docker
Copy the code
  • Check whether the docker versions installed are the same
docker -v 
Copy the code
  • Enable port 2375
/sbin/iptables -I INPUT -p tcp --dport 2375 -j ACCEPT
Copy the code

Set up the Portainer (master management node)

Online installation

  • Creating a Data Volume
docker volume create portainer_data
Copy the code
  • First start Portainer
docker run -d -p 9000:9000 --name=portainer --restart=always -v 
/var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
Copy the code
  • Close & Start the container
Start docker container start portainerCopy the code

Offline installation

  • Creating a Data Volume
docker volume create portainer_data
Copy the code
  • The import
docker load -i /xxxx/portainer.tar
Copy the code
  • Start the Portainer
docker run -d -p 9000:9000 --name=portainer --restart=always -v
/var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
Copy the code
  • Verify that the startup is successful
 docker ps
Copy the code
  • Online configuration
Log in to the active management node and access http://{Management node IP address}:9000Copy the code

To log in for the first time, you need to set your account password and click Ok

Choose Poratiner run mode, there are four options

  • Manage local Docker
  • Manage remote Docker
  • Managed by Portainer-Agent
  • Microsoft Azure Environment

Select local docker, click connect to enter dashboard, you can see local node Primary

You can add nodes for the cluster to be managed through the Portainer administration tool.