Search code examples
dockerdocker-composespring-cloud-config

spring-cloud config runs ok locally but on docker it shows Cannot clone or checkout repository


I'm running Spring Cloud Config Server OK locally, but I want to try docker for the project . and the same code got some errors on docker !

As the config server will pull configs from git , when we are in docker i found the log says :

Cannot clone or checkout repository] with root cause org.eclipse.jgit.errors.CheckoutConflictException: Checkout conflict with files:

I try to delete all the images and clear docker cache and rebuild and re run it , at the end same error shows

spring:
    application:
        name: ace-config
    profiles:
        active: dev
    cloud:
      config:
        server:
          git:
            uri: https://gitlab.com/xxx/myproj.git
            searchPaths: config
            username: xxx
            password: xxx
            default-label: develop

and this is my dockerfile

FROM livingobjects/jre8
VOLUME /tmp
ADD ./target/ace-config.jar app.jar
RUN rm -rf  /tmp/*
RUN bash -c 'touch /app.jar'

and this is my docker-compose.yml

ace-config:
    build: ./ace-config
    image: mipay/ace-config:latest
    restart: always
    depends_on:
    - ace-center
    command: >
      bash -c "
      while ! (nc -z unipay 8761);
      do sleep 5;
      echo 'Waiting for config and center services to start-up...';
      done;
      java -Djava.security.egd=file:/dev/./urandom -jar /app.jar
      "
    ports:
    - "8750:8750"
    extra_hosts:
    - "unipay2:172.31.68.159"
    - "unipay:172.31.68.159"
    - "mipay:172.31.68.159"
    volumes:
    - /opt/logs/:/opt/logs

Solution

  • It's possible you came across this issue:

    https://github.com/spring-cloud/spring-cloud-config/issues/407

    But actually, Spring Cloud Config Server acknowledges that the local copy in the config server can get dirty

    (for example, folder content changes by an OS process)

    For this, a force-pull property can be set to true as documented here.

    Also, as system temporary directory (e.g. /tmp/) can be modified by OS processes, you can specify exactly where you want to put the checked out repository using spring.cloud.config.server.git.basedir as documented here.

    Can you try and see if these helps?