docker / setup-buildx-action

GitHub Action to set up Docker Buildx
https://github.com/marketplace/actions/docker-setup-buildx
Apache License 2.0
984 stars 156 forks source link

Unexpected otel environment variables inside docker buildx build after this action #356

Open MidasLamb opened 1 month ago

MidasLamb commented 1 month ago

Contributing guidelines

I've found a bug, and:

Description

When using this action, when building an image with buildx, it introduces unexpected environment variables related with telemetry.

Expected behaviour

When building busybox image with RUN env, I expect the following during build: (These are the environment variables I get locally and in github actions if I don't use this action and use the provided version on the runner)

#5 [2/2] RUN env
#5 0.126 SHLVL=1
#5 0.126 HOME=/root
#5 0.126 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Actual behaviour

When running busybox image with RUN env, I get a lot more environment variables than expected

#5 [2/2] RUN env
#5 0.043 OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=grpc
#5 0.043 SHLVL=1
#5 0.043 HOME=/root
#5 0.043 OTEL_TRACE_PARENT=00-c721631977cd93d91b16d2c2b54718b2-5684774e47a1b670-01
#5 0.043 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#5 0.043 OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=unix:///dev/otel-grpc.sock
#5 0.043 TRACEPARENT=00-c721631977cd93d91b16d2c2b54718b2-5684774e47a1b670-01
#5 0.043 ***
#5 0.043 OTEL_TRACES_EXPORTER=otlp

Repository URL

No response

Workflow run URL

No response

YAML workflow

name: CI

on:
  pull_request:
    branches:
      - master
      - release/*
jobs:
  midas-test:
    name: Midas Test
    runs-on: ubuntu-22.04

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Build docker
        run: |-
          env
          docker build --progress=plain -f - . <<EOF
          FROM busybox:latest
          RUN env
          EOF

      - name: Build docker bake
        if: always()
        run: |-
          env
          docker buildx bake --file docker-compose.yml --progress=plain --no-cache --load midas

      - name: Build docker build
        if: always()
        run: |-
          env
          docker buildx build --file midas.Dockerfile --progress=plain --no-cache .

      - name: Docker bake
        uses: docker/bake-action@v5
        if: always()
        with:
          files: docker-compose.yml
          push: false
          load: true # Make sure it's in the docker registry, so the next step can get it.
          targets: midas

Workflow logs

No response

BuildKit logs

No response

Additional info

When referring to an image file (midas.Dockerfile), the contents are just:

FROM busybox:latest
RUN env