Search code examples
mysqldockerdocker-composedevopszabbix

Installation of zabbix-server using docker-compose and connect with host mysql and apache server


I am new in docker technology. I want to install zabbix server using docker-compose.yml with only one container and connect it with host machine database(mysql) and also host machine apache2/nginx for zabbix frontend.
Is it possible? Please help.


Solution

  • From the official Zabbix blog tutorial:

    Clone the zabbix-docker repository:

    git clone https://github.com/zabbix/zabbix-docker.git
    cd zabbix-docker
    

    Inside the zabbix-docker directory:

    agent                                       docker-compose_v3_centos_mysql_latest.yaml  docker-compose_v3_ol_pgsql_local.yaml       kubernetes.yaml  snmptraps
    agent2                                      docker-compose_v3_centos_mysql_local.yaml   docker-compose_v3_ubuntu_mysql_latest.yaml  LICENSE          web-apache-mysql
    build.sh                                    docker-compose_v3_centos_pgsql_latest.yaml  docker-compose_v3_ubuntu_mysql_local.yaml   proxy-mysql      web-apache-pgsql
    docker-compose_v3_alpine_mysql_latest.yaml  docker-compose_v3_centos_pgsql_local.yaml   docker-compose_v3_ubuntu_pgsql_latest.yaml  proxy-sqlite3    web-nginx-mysql
    docker-compose_v3_alpine_mysql_local.yaml   docker-compose_v3_ol_mysql_latest.yaml      docker-compose_v3_ubuntu_pgsql_local.yaml   README.md        web-nginx-pgsql
    docker-compose_v3_alpine_pgsql_latest.yaml  docker-compose_v3_ol_mysql_local.yaml       generate-stackbrew-library.sh               server-mysql     web-service
    docker-compose_v3_alpine_pgsql_local.yaml   docker-compose_v3_ol_pgsql_latest.yaml      java-gateway                                server-pgsql     zabbix-appliance
    

    Files ‘docker-compose-v2’ on the left are for an older Docker Compose version. Normally, if you have a fresh installation, you will not need them.

    We will be using Docker Compose v3. What is the difference between those files with docker-compose-v3 in their name?

    • First of all, there is a choice of operating systems: Alpine, CentOS or Ubuntu — three choices of distribution on which to run the container.
    _alpine_
    _centos_
    _ubuntu_
    
    • Then, there is a choice of databases which could be MySQL or Postgres. For each distribution you have a choice of database engines.
    _mysql_
    _pgsql_
    
    • Last of all, there are two types — local and latest. The difference between those two is pretty simple.
    _latest.yaml
    _local.yaml
    
    • Local means that we will be building an image locally from our local Docker files.

    • Latest means that we will be pulling it from the repository.

    Checkout the version of Zabbix you want:

    git checkout 5.0
    

    Run one of the docker-compose files 1:

    docker-compose -f docker-compose_v3_alpine_mysql_latest.yaml up -d
    

    1 Checkout the available ports, otherwise the services may fail to start.

    Read their turorial for more information.