Setting arguments in docker-compose file

Hi I want to use the haproxy exporter provided here https://github.com/prometheus/haproxy_exporter in a docker container.

I am using docker-composefor managing containers and want to recreate this command:

  • Dockerfile with nesting via non-master branches
  • connect .NET API running in linux container with SQL Server running in VM using windows auth
  • Running Grapevine REST server in Mono Docker container
  • Docker over Linux but running Windows inside
  • Why does using DOCKER_OPTS=“--iptables=false” break the DNS discovery for docker-compose?
  • Regarding not getting GNU awk version after creating a docker basic container
  • $ docker run -p 9101:9101 prom/haproxy-exporter -haproxy.scrape-uri="http://user:pass@haproxy.example.com/haproxy?stats;csv"
    

    in my docker-compose.yml.

    I am not sure how to pass the argument, after viewing the docker-compose documentation I tried it like this:

      haproxy-exporter:
        image: prom/haproxy-exporter
        ports:
          - 9101:9101
        network_mode: "host"
        build:
          args:
            - haproxy.scrape-uri="http://user:pass@haproxy.example.com/haproxy?stats;csv"
    

    But this gives me an file is invalid message because it requires a context with a build.

    Thanks for any help in advance

  • Tag docker image after successful testing
  • accessing the docker container for rabbitmq from ubuntu host
  • Docker-compose, deploy war to Tomcat, run oracle service
  • Registrator not listening to docker events
  • How to remove old Docker containers
  • Splash stops with error “unregister_netdevice: waiting for lo to become free”
  • One Solution collect form web for “Setting arguments in docker-compose file”

    The image is already built and pulled from the hub (unless you have your own Dockerfile) so you don’t need the build option. Instead, pass your arguments as the command since the image appears to use an entrypoint (if their Dockerfile only had a cmd option, then you’d need to also pass /bin/haproxy-exporter in your command):

     haproxy-exporter:
        image: prom/haproxy-exporter
        ports:
          - 9101:9101
        network_mode: "host"
        command: -haproxy.scrape-uri="http://user:pass@haproxy.example.com/haproxy?stats;csv"
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.