5

I am trying to run project in(by means of) docker. It works properly on unix servers. I am using Windows on my local machine.

Project structure looks like this:
enter image description here

docker-compose.yml content:

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 file content:

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

Then I execute following command:

docker-compose -f docker-compose.yml up

result:

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

What do I wrong? How to fix this error?

P.S.

I use Gradle 4.6

gstackoverflow
  • 36,709
  • 117
  • 359
  • 710

3 Answers3

3

See https://stackoverflow.com/a/39345276/372019:

Please add the following command in your Dockerfile before the RUN gradle build command:

RUN apk add --no-cache libstdc++
gesellix
  • 3,024
  • 28
  • 31
1

There seems to be several issues in github related to this, though not explicitly mentioning Windows host

Some of the things people mentioned that were fixing the issue for them:

  • using newer cradle, gradle 3.5 was reported to work whereas previous versions did not. At least confirm you're not running an older version.
  • GRADLE_USER_HOME environment variable not being set or accessible for the user running, which you should also confirm: chmod 000 $GRADLE_USER_HOME
  • running container using --privileged flag
  • running as root (not recommended if you can get this to work otherwise):

Dockerfile for running as root:

FROM gradle:alpine
USER root
eis
  • 51,991
  • 13
  • 150
  • 199
1

Since the gradle machine is not having complete permission to execute gradle commands, Can you try running the docker machine with user permission as "root user"

FROM gradle:alpine
USER root

or you execute the docker run command with "-u root" arguments,

For more details refer: https://github.com/keeganwitt/docker-gradle/issues/29

Bharathan Kumaran
  • 981
  • 10
  • 22