Skip to content

Unable to run envoy binary inside envoy-gateway container image #5033

Closed

Description

@dshatokhin

Description:

I'm trying to run envoy-gateway in standalone mode in a container using
provided image envoyproxy/gateway:v1.2.4. I'm reproducing steps from article Standalone Deployment Mode but instead of binary image mentioned above is used.

The envoy binary successfully got downloaded but can't start with no such file or directory error.

This is common error when trying to run dynamically linked binary in a distroless image.

Instead of an error envoy should be able to start inside running container.

Repro steps:

Here are steps to reproduce, requires installed docker:

# Put standalone.yaml file from the article in the docs (only 'paths' field changed)
$ cat << EOF > /tmp/standalone.yaml
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyGateway
gateway:
  controllerName: gateway.envoyproxy.io/gatewayclass-controller
provider:
  type: Custom
  custom:
    resource:
      type: File
      file:
        paths: ["/tmp/envoy-gateway/config"]
    infrastructure:
      type: Host
      host: {}
logging:
  level:
    default: debug
extensionApis:
  enableBackend: true
EOF

# Create directory for configs and widen the permissions (needed to be accessible inside container)
$ mkdir -p /tmp/envoy-gateway/config
$ sudo chmod -R 777 /tmp/envoy-gateway/

# Generate certificates and put them in a mounted directory
$ docker run --rm -v /tmp/envoy-gateway:/tmp/envoy-gateway envoyproxy/gateway:v1.2.4 certgen --local
2025-01-10T21:51:13.559Z        INFO    cmd/server.go:106       No config file provided, using default parameters
2025-01-10T21:51:14.318Z        INFO    cmd/certgen.go:71       generated certificates  {"path": "/tmp/envoy-gateway/certs"}

# Download quickstart.yaml
$ wget -q https://raw.githubusercontent.com/envoyproxy/gateway/refs/heads/main/examples/standalone/quickstart.yaml -O /tmp/envoy-gateway/config/quickstart.yaml

# Start 'envoy-gateway' with created config
$ docker run --rm -v /tmp/envoy-gateway:/tmp/envoy-gateway -v /tmp/standalone.yaml:/tmp/standalone.yaml envoyproxy/gateway:v1.2.4 server --config-path /tmp/standalone.yaml
. . .
downloading https://archive.tetratelabs.io/envoy/download/v1.32.3/envoy-v1.32.3-linux-amd64.tar.xz
starting: /tmp/envoy-gateway/versions/1.32.3/bin/envoy --service-cluster envoy-gateway-system/eg --service-node envoy-gateway-system-eg-5391c79d --config-yaml ...
. . .
2025-01-10T22:26:47.825Z        ERROR   infrastructure  runner/runner.go:104    failed to create new infra      {"runner": "infrastructure", "error": "unable to start Envoy process: fork/exec /tmp/envoy-gateway/versions/1.32.3/bin/envoy: no such file or directory"}
2025-01-10T22:26:47.825Z        ERROR   watchable       message/watchutil.go:56 observed an error       {"runner": "infrastructure", "error": "unable to start Envoy process: fork/exec /tmp/envoy-gateway/versions/1.32.3/bin/envoy: no such file or directory"}

Since binary successfully downloaded and now stored on the host we can do more experiments.

Running envoy binary inside gcr.io/distroless/static:nonroot which is used to build envoy-gateway image (see envoyproxy/gateway/tools/docker/envoy-gateway/Dockerfile):

$ docker run --rm -v /tmp/envoy-gateway:/tmp/envoy-gateway gcr.io/distroless/static:nonroot /tmp/envoy-gateway/versions/1.32.3/bin/envoy --version
exec /tmp/envoy-gateway/versions/1.32.3/bin/envoy: no such file or directory

Now running the same binary using gcr.io/distroless/base-nossl-debian12:nonroot which is used to build envoy image (see envoyproxy/envoy/ci/Dockerfile-envoy):

$ docker run --rm -v /tmp/envoy-gateway:/tmp/envoy-gateway gcr.io/distroless/base-nossl-debian12:nonroot /tmp/envoy-gateway/versions/1.32.3/bin/envoy --version
/tmp/envoy-gateway/versions/1.32.3/bin/envoy  version: 58bd599ebd5918d4d005de60954fcd2cb00abd95/1.32.3/Clean/RELEASE/BoringSSL

To ensure what the binary is dynamically linked linux command file can be utilised:

$ sudo file /tmp/envoy-gateway/versions/1.32.3/bin/envoy
/tmp/envoy-gateway/versions/1.32.3/bin/envoy: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=58bd599ebd5918d4d005de60954fcd2cb00abd95, stripped

Environment:
Linux x64, docker

Activity

  1. arkodg commented on Jan 10, 2025

    @arkodg
    Contributor
  2. mathetake commented on Jan 11, 2025

    @mathetake
    Member

    this is not an issue of either envoy or envoy gateway. envoy binaries are NOT fully static binary but as you see dynamically linked to glibc just like normal c/c++/rust applications, not possible to execute in the environment without glibc. maybe you want to try building envoy with musl libc to produce the fully static binary but i don't think it would be worth your effort vs the gain.

  3. arkodg commented on Jan 11, 2025

    @arkodg
    Contributor
  4. mathetake commented on Jan 11, 2025

    @mathetake
    Member

    yeah that might help i guess (i thought the issue was to run envoy in distroless-static, which is not possible as i mentioned, but it seems like the request here is the other way around)

  5. arkodg commented on Jan 11, 2025

    @arkodg
    Contributor

    yeah @denniskniep was trying to run standalone envoy-gateway in the envoy-gateway container itself, which would fork a envoy process !

    tried out gcr.io/distroless/base-nossl and it works, image size increases by ~6MB

  6. added a commit that references this issue on Jan 11, 2025
  7. arkodg commented on Jan 11, 2025

    @arkodg
    Contributor

    hey @dshatokhin raised #5034 to address this, would be great if you can enhance the docs to include your steps in the standalone doc once the PR is in.
    cc @shawnh2

  8. dshatokhin commented on Jan 12, 2025

    @dshatokhin
    ContributorAuthor

    @arkodg sure, I would like to help the project 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions