java - Windows 中的 Docker : Failed to load native library 'libnative-platform.so' for Linux amd64

标签 java windows docker gradle docker-compose

<分区>

我正在尝试在(通过)docker 中运行项目。它在 unix 服务器上正常工作。我在本地计算机上使用 Windows。

项目结构如下所示:
enter image description here

docker-compose.yml内容:

version: '3'
services:
  sftp:
    image: atmoz/sftp
    restart: on-failure
    command: missftp:missftp:::destWorking,destRejected,destSuccess,attachments
  mailer:
    image: mailhog/mailhog
    ports:
      - 8025:8025
      - 1025:1025
    restart: on-failure
  mongo:
    image: mongo
    restart: on-failure
  mongo-express:
    image: mongo-express
    restart: on-failure
    ports:
      - 8081:8081
    environment:
      - ME_CONFIG_MONGODB_SERVER=mongo
      - ME_CONFIG_BASICAUTH_USERNAME=admin
      - ME_CONFIG_BASICAUTH_PASSWORD=1234
  data-service:
    build:
      context: .
      dockerfile: Dockerfile.data-service
    ports:
      - 8801:8801
      - 8802:8802
    restart: on-failure
    volumes:
         - /opt/app/mis/attachments:/attachments
    environment:
      - SPRING_DATA_MONGODB_HOST=mongo
      - SPRING_MAIL_HOST=mailer
      - SPRING_MAIL_USERNAME=apikey
      - SPRING_MAIL_PASSWORD=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
      - SPRING_MAIL_PORT=465
      ...
  upload-service:
    build:
      context: .
      dockerfile: Dockerfile.upload-service
    ports:
      - 8082:8082
      - 8083:8083
    restart: on-failure
    environment:
      - SPRING_DATA_MONGODB_HOST=mongo
      ...

Dockerfile.data-service 文件内容:

FROM gradle:alpine
COPY / ./
RUN gradle build
ENTRYPOINT java -jar ./mis-data-service/build/libs/mis-data-service-0.1.jar

然后我执行以下命令:

docker-compose -f docker-compose.yml up

结果:

Building data-service
Step 1/4 : FROM gradle:alpine
 ---> f438b7d58d0a
Step 2/4 : COPY / ./
 ---> Using cache
 ---> b72d0e76b86c
Step 3/4 : RUN gradle build
 ---> Running in 7ba780a524e5

FAILURE: Build failed with an exception.

* What went wrong:
Failed to load native library 'libnative-platform.so' for Linux amd64.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org
ERROR: Service 'data-service' failed to build: The command '/bin/sh -c gradle build' returned a non-zero code: 1

我做错了什么?如何修复此错误?

附言

我使用 Gradle 4.6

最佳答案

参见 https://stackoverflow.com/a/39345276/372019 :

请在您的 Dockerfile 中 RUN gradle build 命令之前添加以下命令:

RUN apk add --no-cache libstdc++

关于java - Windows 中的 Docker : Failed to load native library 'libnative-platform.so' for Linux amd64,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50271985/

相关文章:

java - 对文件系统上的 XML 文件进行快速全文搜索。选择什么策略?

c++ - 如何为多线程应用程序制作全局对象

docker - 运行Docker容器时如何附加到PATH环境变量?

如果 for 循环有空变量,windows 批处理会出错

docker-compose up 失败并显示 "Unable to find a node that satisfies the following conditions "

linux - 在 Docker for Windows 中创建符号链接(symbolic link)失败,还不支持吗?

java - 访问 Java 中的包

java - 用java读取乌尔都语文件

java - calendar.add 在 Android 中无法正常运行

windows - 在 Windows 下使用 GIT with/SSH key 文件的问题