title: How do I run a docker compose file with modified telegraf config file?
body: <p>I'm trying to run a docker compose file on MacOS to run Telegraf, Mosquitto (MQTT), Grafana and InfluxDB. I'm trying to run Telegraf with a modified config file. The ultimate aim is to store and display data being sent from an arduino muscle sensor. </p>
  
  <p>The docker compose file currently looks like this:</p>
  
  <pre><code>version: '3'
  
  services: 
    influxdb:
      container_name: influxdb
      image: influxdb
      ports:
          - "8086:8086"
      environment:
        - INFLUXDB_DB=sensors
        - INFLUXDB_ADMIN_USER=telegraf
        - INFLUXDB_ADMIN_PASSWORD=telegraf
      restart: always
  
    telegraf: 
      image: telegraf
      restart: always
      ports: 
        - "5050:5050"
      volumes:
      - $PWD/telegraf.conf:/etc/telegraf/telegraf.conf:ro  
  
    grafana: 
      container_name: grafana
      image: grafana/grafana
      links:
        - influxdb
      hostname: grafana
      ports:
          - "3000:3000"
  
    mosquitto:
      container_name: mosquitto
      image: eclipse-mosquitto
      ports:
        - "1883:1883"
        - "9001:9001"
      depends_on: 
        - influxdb
      restart: always
  </code></pre>
  
  <p>I can run the build command and Mosquitto, Grafana and InfluxDB all seem to run however there are a number of issues with Telegraf. Regardless of what changes are made to volume in the compose file the default config file for Telegraf is used, as opposed to my modified config, which seems to prevent data being sent to InfluxDB.</p>
  
  <p>The Telegraf post to InfluxDB error looks as follows:</p>
  
  <pre><code>telegraf     | 2020-03-03T11:40:49Z E! [outputs.influxdb] When writing to [http://localhost:8086]: Post http://localhost:8086/write?db=telegraf: dial tcp 127.0.0.1:8086: connect: connection refused
  telegraf     | 2020-03-03T11:40:49Z E! [agent] Error writing to outputs.influxdb: could not write any address
  </code></pre>
  
  <p>Mosquitto seems to work as the MQTT.fx app is able to connect and publish/subscribe to the container. However there are regular connections made and dropped with an unknown name.</p>
  
  <p>The following connection error continuously logs:</p>
  
  <pre><code>mosquitto    | 1583247033: New connection from 172.25.0.1 on port 1883.
  mosquitto    | 1583247033: Client &lt;unknown&gt; disconnected due to protocol error.
  </code></pre>
  
  <p>I've considered writing a Telegraf dockerfile to set the config file however this seems like overkill as my understanding is that the volume section of the compose file should allow this config file to be used.</p>
  
  <p>My telegraf.conf file is in the same directory as the docker-compose.yml file.</p>
  
  <p>The question is
  a) Is my belief that the container is using the default telegraf file correct
  b) How do I get the altered telegraf.conf file to on the container</p>