Environmental deployment
2 physical machine: zabbix-server 192.168.233.96 zabbix-agent 192.168.233.95
docker version: (docker --virsion or docker info can see) Server Version: 19.03.1
zabbix version: (/ usr / local / zabbix / sbin / zabbix_server --V can see) zabbix 4.0
docker mirror source :( downloaded to /etc/yum.repo.d/ directory) wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Installation docker
yum install docker-ce -y (Free Edition is -ce business community paid version is -ee)
Time to resolve dependencies may report the following error
Error: Package: containerd.io-1.2.6-3.3.el7.x86_64 (docker-ce-stable) Requires: container-selinux >= 2:2.74Error reason: low container-selinux package required version requires version 2.74
Solution: The official website mirror.centos.org to find the required version of the package, download and install
yum -y install http://mirror.centos.org/centos-7/7/extras/x86_64/Packages/container-selinux-2.74-1.el7.noarch.rpm
Log Ali cloud -> Go to Control Panel -> Services -> Container Services Mirror -> Mirror accelerator
Write a script and execute (implement mirroring acceleration)
#!/bin/bash sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://m8ce5kzp.mirror.aliyuncs.com"] } EOF sudo systemctl daemon-reload sudo systemctl restart docker
Use docker-compose choreography yaml file
[root@master ~]# cat docker-compose.yaml version: '3.3' services: mysql-server: container_name: mariadb-server image: mariadb:10.2 restart: always environment: MYSQL_DATABASE: zabbix MYSQL_USER: zabbix MYSQL_PASSWORD: zabbix MYSQL_ROOT_PASSWORD: root volumes: - /data/mysql/data/:/var/lib/mysql - /data/mysql/conf/:/etc/my.cnf.d/server.cnf zabbix-server: container_name: zabbix-server image: zabbix/zabbix-server-mysql restart: always environment: DB_SERVER_HOST: "mysql-server" MYSQL_DATABASE: "zabbix" MYSQL_USER: "zabbix" MYSQL_PASSWORD: "zabbix" MYSQL_ROOT_PASSWORD: "root" ports: - 10051:10051 links: - mysql-server zabbix-web: container_name: zabbix-web image: zabbix/zabbix-web-apache-mysql restart: always depends_on: - mysql-server - zabbix-server environment: DB_SERVER_HOST: "mysql-server" MYSQL_DATABASE: "zabbix" MYSQL_USER: "zabbix" MYSQL_PASSWORD: "zabbix" MYSQL_ROOT_PASSWORD: "root" ports: - 80:80 links: - mysql-server - zabbix-server
When deployed with mariadb10.2 zabbix the best versions of the following, including 10.2 as 10.3.17 version has some restrictions on the length of the field, this will lead to error down data when it directly with 10.2, 10.2 is mariadb a stable version given in the official website, or a good use
After use interface are zabbix
The process of creating containers docker-compose
# Start container docker-compose.yaml defined in the document, and is running in the background [root @ master ~] # docker -compose up -d
Usage docker-compose command
Commands: build Build or rebuild services bundle Generate a Docker bundle from the Compose file config Validate and view the Compose file create Create services down Stop and remove containers, networks, images, and volumes events Receive real time events from containers exec Execute a command in a running container help Get help on a command images List images kill Kill containers logs View output from containers pause Pause services port Print the public port for a port binding ps List containers pull Pull service images push Push service images restart Restart services rm Remove stopped containers run Run a one-off command scale Set number of containers for a service start Start services stop Stop services top Display the running processes unpause Unpause services up Create and start containers version Show the Docker-Compose version information
build or re-build services help command help pause to pause the service exec into a docker container interface kill kill container logs show docker-compose.yaml file output the contents of the container ps shows the active container pull the pull service mirroring restart to restart the service rm delete stop container run run container number of containers scale settings of the service start to open service stop stop the service up to create and launch container
config test docker-comose.yaml file syntax is ok
Syntax Parameters docker-compose.yaml instructions in the file
A docker-compose.yaml file broadly divided into: version, services, network
version
version can be 1,2,3 This is a great version, there is a small version, such as 1.0,2.2,3.3, etc., must be developed version version when defining yaml files, each version of the syntax may not be the same, can refer to the article below to the official documentation for details
service
1.service defined service name, service under a defined service name
Version: '3.3' Services: Service Name:
2. Under the name of a service tag has container_name, image, restart, privileged, environment, volumes, ports, links, etc.
container_name: Name vessel defined image: Mirror Name restart restart: "NO" # do not restart restart: always # always restart restart: on-failure when the failure to restart # restart: unless-stopped # unless stopped privileged: get the highest authority environment: set system environment variables KEY1: VALUE1 the KEY2: VALUE2 volumes mapping container volume - host_path: CONTAINER_PATH - host_path: CONTAINER_PATH the ports: port mapping container - host_port: CONTAINER_PORT links: connecting the container - SERVICE_NAME depends_on: definition of container in the order - ZABBIX-Server - ZABBIX -web - MySQL-Server
Syntax more docker-compose documents refer to https://docs.docker.com/compose/compose-file/