Article directory
Docker installation
Download address: https://download.docker.com/linux/static/stable/x86_64/
-
Upload installation package via file transfer tool
-
Unzip and install
tar -xzvf docker-18.03.1-ce.tgz -C /home/
- Copy the binary file to the /usr/bin directory
cp /home/docker/* /usr/bin/
- 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
#######################################################
- Close selinux service
vi /etc/selinux/config
---------------------------------------------------------------
# 修改参数,SELINUX=参数,参数可选(enforcing、permissive、disabled)
SELINUX=disabled
- 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
- Import image files offline
docker load -i image_portainer.tar
- Create data directory
cd /home &&mkdir portainer_data
- 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
home page