在 Docker 中安装 GCP Profiler 代理时遇到问题

Trouble in installing GCP Profiler agent in Docker

我正在尝试为我在 GKE 中运行的应用程序安装 GCP Profiler 代理,按照此处的说明进行操作:https://cloud.google.com/profiler/docs/profiling-java

我无法克服这个错误。有人可以帮忙吗?

Could not find agent library /opt/cprof/profiler_java_agent.so in absolute path, with error: Error relocating /opt/cprof/profiler_java_agent.so: __pthread_key_create: initial-exec TLS resolves to dynamic definition in /opt/cprof/profiler_java_agent.so

这是 Dockerfile

FROM openjdk:8-jdk-alpine
RUN apk update && apk add --no-cache gcompat
RUN apk update && apk add --no-cache libc6-compat

WORKDIR /app

# The application's jar file
ARG JAR_FILE=target/example-svc-*.jar

# Add the application's jar to the container
ADD ${JAR_FILE} example-svc.jar

EXPOSE 5050

RUN mkdir -p /opt/cprof && \
  wget -q -O- https://storage.googleapis.com/cloud-profiler/java/latest/profiler_java_agent.tar.gz \
  | tar xzv -C /opt/cprof

ENTRYPOINT ["java", \
    "-agentpath:/opt/cprof/profiler_java_agent.so=-cprof_service=example-svc,-cprof_service_version=0.0.1-SNAPSHOT", \
    "-jar", "/app/example-svc.jar"]

问题似乎出在您使用的容器映像的基础版本上。查看您的 Dockerfile,您从:

openjdk:8-jdk-alpine

深入研究这个文档,我们发现:

The main caveat to note is that it does use musl libc instead of glibc and friends, so certain software might run into issues depending on the depth of their libc requirements.

(参考:openjdk

现在,如果我们查看 Google 文档 here,我们会发现定义了以下要求:

Supported operating systems:

  • Linux versions whose standard C library is implemented with glibc.

...这似乎是一个冲突。请尝试使用不基于 alpine.

的替代版本的 openjdk 图像