title: What is the difference between docker run --config vs docker compose config?
body: <p>So what I am looking at is a <strong>docker run</strong> command being used in to create a docker container for open telemetry that passes in a <strong>config</strong> command, and the code looks like...</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>$ git clone git@github.com:open-telemetry/opentelemetry-collector.git; \
      cd opentelemetry-collector/examples; \
      go build main.go; ./main &amp; pid1="$!";
      docker run --rm -p 13133:13133 -p 14250:14250 -p 14268:14268 \
        -p 55678-55679:55678-55679 -p 4317:4317 -p 8888:8888 -p 9411:9411 \
        -v "${PWD}/local/otel-config.yaml":/otel-local-config.yaml \
        --name otelcol otel/opentelemetry-collector \
        --config otel-local-config.yaml; \
      kill $pid1; docker stop otelcol</code></pre>
  </div>
  </div>
  </p>
  <p>(<a href="https://opentelemetry.io/docs/collector/getting-started/#docker" rel="nofollow noreferrer">https://opentelemetry.io/docs/collector/getting-started/#docker</a>)</p>
  <p>What I don't understand is how a <strong>non-docker</strong> related <strong>config file</strong>(open telemetry config) fits into the &quot;<strong>docker run --config</strong>&quot; or &quot;<strong>docker compose config</strong>&quot; commands. Below is the open telemetry config file that seems to be non-docker related</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>extensions:
    memory_ballast:
      size_mib: 512
    zpages:
      endpoint: 0.0.0.0:55679
  
  receivers:
    otlp:
      protocols:
        grpc:
        http:
  
  processors:
    batch:
    memory_limiter:
      # 75% of maximum memory up to 4G
      limit_mib: 1536
      # 25% of limit up to 2G
      spike_limit_mib: 512
      check_interval: 5s
  
  exporters:
    logging:
      logLevel: debug
  
  service:
    pipelines:
      traces:
        receivers: [otlp]
        processors: [memory_limiter, batch]
        exporters: [logging]
      metrics:
        receivers: [otlp]
        processors: [memory_limiter, batch]
        exporters: [logging]
  
    extensions: [memory_ballast, zpages]</code></pre>
  </div>
  </div>
  </p>
  <p><a href="https://github.com/open-telemetry/opentelemetry-collector/blob/main/examples/local/otel-config.yaml" rel="nofollow noreferrer">https://github.com/open-telemetry/opentelemetry-collector/blob/main/examples/local/otel-config.yaml</a></p>
  <p>Now I have looked at these <strong>Docker</strong> links</p>
  <p><a href="https://docs.docker.com/engine/swarm/configs/#how-docker-manages-configs" rel="nofollow noreferrer">https://docs.docker.com/engine/swarm/configs/#how-docker-manages-configs</a></p>
  <p><a href="https://nickjanetakis.com/blog/docker-tip-43-using-the-docker-compose-config-command" rel="nofollow noreferrer">https://nickjanetakis.com/blog/docker-tip-43-using-the-docker-compose-config-command</a></p>
  <p>but I couldn't figure out how to get the <strong>docker run --config</strong> command in the <em>open telemetry</em> example to start working in docker compose with <strong>docker compose config</strong>. Here is my docker compose</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>version: "3.9"
  
  services:
    opentelemetry:
      container_name: otel
      image: otel/opentelemetry-collector:latest
      volumes:
        - ~/source/repos/CritterTrackerProject/DockerServices/OpenTelemetry/otel-collector-config.yml:/otel-local-config.yml
      config:
        - otel-local-config.yml
      ports:
        - 13133:13133
        - 14250:14250
        - 14268:14268
        - 55678-55679:55678-55679
        - 4317:4317
        - 8888:8888
        - 9411:9411
      extra_hosts:
        - "host.docker.internal:host-gateway"
      networks:
        - my-network
  
    jaeger:
      # restart: unless-stopped
      container_name: jaeger
      image: jaegertracing/all-in-one:latest
      ports:
        - 16686:16686
        # - 14250:14250
        # - 14268:14268
        # - 5775:5775/udp
        - 6831:6831/udp
        # - 6832:6832/udp
        # - 5778:5778
        # - 9411:9411
      extra_hosts:
        - "host.docker.internal:host-gateway"
      networks:
        - my-network
  
    postgres:
     restart: always
     container_name: postgres
     image: postgres:latest
     environment:
       - POSTGRES_USER=code
       - POSTGRES_PASSWORD=code
     ports:
       - 5432:5432
     volumes: 
       - postgres:/var/lib/postgresql/data
     extra_hosts:
       - "host.docker.internal:host-gateway"
     networks:
       - my-network
  
    nginx:
      restart: always
      container_name: webserver
      image: nginx:latest
      build:
        context: ~/source/repos/CritterTrackerProject
        dockerfile: DockerServices/Nginx/Dockerfile
      ports:
        - 80:80
        - 443:443
      extra_hosts:
        - "host.docker.internal:host-gateway"
      networks:
        - my-network
  
  volumes:
    postgres:
  
  networks:
    my-network:
      external: true
      name: my-network</code></pre>
  </div>
  </div>
  </p>
  <p>Here is my error after running <strong>docker compose up</strong> in a Git Bash terminal</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>$ docker compose -f ./DockerServices/docker-compose.yml up -d
  services.opentelemetry Additional property config is not allowed</code></pre>
  </div>
  </div>
  </p>