Docker and Portainer Installation and User Manual

Docker installation

Download address: https://download.docker.com/linux/static/stable/x86_64/

  1. Upload installation package via file transfer tool

  2. Unzip and install

tar -xzvf docker-18.03.1-ce.tgz -C /home/
  1. Copy the binary file to the /usr/bin directory
cp /home/docker/* /usr/bin/
  1. Configure docker.service file
vi /usr/lib/systemd/system/docker.service

################### 写入以下内容 #########################
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target

[Service]
Type=notify
EnvironmentFile=-/etc/default/docker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP
LimitNOFILE=infinity
LimitNPROC=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s

[Install]
WantedBy=multi-user.target
#######################################################
  1. Close selinux service
vi /etc/selinux/config
---------------------------------------------------------------
# 修改参数,SELINUX=参数,参数可选(enforcing、permissive、disabled)
SELINUX=disabled
  1. Start docker service
systemctl daemon-reload            #刷新系统服务配置文件
systemctl start docker.service     #启动docker
systemctl enable docker.service    #配置开机自启
systemctl status docker.service    #查看docker状态 

Docker configuration modification

Join Portainer management and use

  • Add configuration "-H tcp://0.0.0.0:2375" to enable port 2375 of docker api.
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target

[Service]
Type=notify
EnvironmentFile=-/etc/default/docker
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
ExecReload=/bin/kill -s HUP
LimitNOFILE=infinity
LimitNPROC=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s

[Install]
WantedBy=multi-user.target

Modify the IP address of Docker0

vi /etc/default/docker 
# 写入想要修改 IP 地址段
DOCKER_OPTS="--bip=172.20.1.0/16"

Modify Docker storage location

  • Add the configuration "--data-root=/home/southgisdata/docker" to modify the storage directory, and /home/southgisdata/docker is the adjusted back-end storage directory.
vim /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target

[Service]
Type=notify
EnvironmentFile=-/etc/default/docker
ExecStart=/usr/bin/dockerd --data-root=/home/southgisdata/docker
ExecReload=/bin/kill -s HUP
LimitNOFILE=infinity
LimitNPROC=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s

[Install]
WantedBy=multi-user.target

Set container retention log size

Create a new "/etc/docker/daemon.json" if it exists. There is no need to create a new one. Add log-dirver and log-opts parameters, the sample is as follows:
Note: You need to start the docker service before making modifications, and restart the docker service after modification.

# 编辑 daemon.json 文件
vi /etc/docker/daemon.json
# 写入
{
  "log-driver":"json-file",
  "log-opts": {"max-size":"500m", "max-file":"4"}
}

max-size=500m means that the upper limit of the log size of a container is 500M.
max-file=4 means that a container has three logs, namely id+.json, id+1.json, id+2.json, id+ 3.json.

Portainer installation

Download address: https://hub.docker.com/r/portainer/portainer-ce/tags

  1. Import image files offline
docker load -i image_portainer.tar
  1. Create data directory
cd /home &&mkdir portainer_data
  1. Run container
docker run -d --name portainer --restart=always -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v /opt/portainer_data/:/data 192.168.10.156/fpa/portainer:latest

Portioner uses

Access address: http://portainer installation server ip:9000/

Log in
Insert image description here

home page
Insert image description here

Guess you like

Origin blog.csdn.net/weixin_41166785/article/details/120767702