首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >对接器运行-配置和坞库组合配置之间有什么区别?

对接器运行-配置和坞库组合配置之间有什么区别?
EN

Stack Overflow用户
提问于 2022-02-19 08:13:44
回答 2查看 169关注 0票数 0

因此,我看到的是一个停靠程序运行命令,用于创建一个用于开放遥测的码头容器,该容器传递一个配置命令,代码看起来像.

代码语言:javascript
运行
复制
$ git clone git@github.com:open-telemetry/opentelemetry-collector.git; \
    cd opentelemetry-collector/examples; \
    go build main.go; ./main & 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

(https://opentelemetry.io/docs/collector/getting-started/#docker)

我不明白的是,非码头配置文件相关的配置文件(开放遥测配置)是如何与“停靠器运行-配置配置文件”或“对接者组合配置配置文件”命令相匹配的。下面是打开的遥测配置文件,该文件似乎与非码头相关。

代码语言:javascript
运行
复制
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]

https://github.com/open-telemetry/opentelemetry-collector/blob/main/examples/local/otel-config.yaml

现在我看了这些Docker链接

https://docs.docker.com/engine/swarm/configs/#how-docker-manages-configs

https://nickjanetakis.com/blog/docker-tip-43-using-the-docker-compose-config-command

但是,我不知道如何在开放的遥测示例中获得docker运行-config命令,以便在docker 中开始工作。这是我的码头作曲

代码语言:javascript
运行
复制
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

以下是我在Git Bash终端中运行码头组装后的错误

代码语言:javascript
运行
复制
$ docker compose -f ./DockerServices/docker-compose.yml up -d
services.opentelemetry Additional property config is not allowed

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-02-19 11:43:35

docker run的一般形式是

代码语言:javascript
运行
复制
docker run [docker options] image [command]

如果您查看原始命令,它将与此模式相匹配。

代码语言:javascript
运行
复制
docker run \
  --rm -p ... -v ... --name ... \  # Docker options
  otel/opentelemetry-collector \   # Image
  --config otel-local-config.yaml  # Command

因此,看起来像--config选项的实际上是容器设置的命令部分;它覆盖Dockerfile CMD,它是passed as additional arguments to the image's ENTRYPOINT

那么,在组合设置中,这将是容器的command:

代码语言:javascript
运行
复制
services:
  opentelemetry:
    image: otel/opentelemetry-collector:latest
    command: --config otel-local-config.yaml

因为这是一个特定于应用程序的命令字符串,所以它与docker-compose config命令无关,它是一个诊断工具,它只是将部分组合配置转储出去。

票数 1
EN

Stack Overflow用户

发布于 2022-02-19 08:34:32

在docker命令中所做的工作是进行以下安装:

本地主机上的${PWD}/ local /otel-config.yaml从码头内部到/otel-local-config.yaml

您可以使用来自的卷选项实现相同的行为:

卷数:

  • "${PWD}/local/otel-config.yaml":/otel-local-config.yaml
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71183264

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档