1

i tried an old project to run, it worked back then perfectly, a few months ago, but now i receive next error when i'm trying to start keycloak container from Docker-Compose file:

ERROR: for keycloak  Cannot create container for service keycloak: invalid volume specification: 'C:\Users\com.springmicroservicesinaction\facultateservice\realm-export.json:/opt/jboss/keycloak/realm-export.json:rw'

My Docker-Compose file:

version: '3'
services:

  keycloak:
    image: jboss/keycloak
    container_name: keycloak
    restart: always
    environment:
      DB_VENDOR: MYSQL
      DB_ADDR: database
      DB_DATABASE: petrea
      DB_USER: root
      DB_PASSWORD: ravage123
      KEYCLOAK_USER: admin
      KEYCLOAK_PASSWORD: admin
      #    KEYCLOAK_LOGLEVEL: DEBUG
      JDBC_PARAMS: "connectTimeout=30000"
    volumes:
      - "./realm-export.json:/opt/jboss/keycloak/realm-export.json"
    command:
      - "-b 0.0.0.0"
      - '-Dkeycloak.import=/opt/jboss/keycloak/realm-export.json'
      - "-Dkeycloak.profile.feature.scripts=enabled"
      - "-Dkeycloak.profile.feature.upload_scripts=enabled"
    ports:
      - "8080:8080"
    depends_on:
      - database
    networks:
      - spring-cloud-network

What the reason? Please help me understanding what i did wrong

MyProblems
  • 69
  • 1
  • 10
  • I believe docker-compose cannot interpret a Windows path correctly. Check: https://stackoverflow.com/questions/35315996/how-do-i-mount-a-docker-volume-while-using-a-windows-host – HiroCereal Oct 28 '22 at 21:31
  • ok, i added double // at the begining of the path, something like this: "//C:/Users/marius/com.springmicroservicesinaction/facultateservice/realm-export.json:/opt/jboss/keycloak/realm-export.json" but now error is: ERROR: for keycloak Cannot create container for service keycloak: invalid mode: /opt/jboss/keycloak/realm-export.json ---- so invalid mode is mounted volume on keycloak container... – MyProblems Oct 29 '22 at 06:13

1 Answers1

0

Update, solution was:

version: '2.1'
services:

  keycloak:
    image: jboss/keycloak
    container_name: keycloak
    restart: always
    environment:
      DB_VENDOR: MYSQL
      DB_ADDR: database
      DB_DATABASE: petrea
      DB_USER: root
      DB_PASSWORD: ravage123
      KEYCLOAK_USER: admin
      KEYCLOAK_PASSWORD: admin
      #    KEYCLOAK_LOGLEVEL: DEBUG
      JDBC_PARAMS: "connectTimeout=30000"
    volumes:
      - "//./realm-export.json:/opt/jboss/keycloak/realm-export.json"
    command:
      -b 0.0.0.0
      -Dkeycloak.import=/opt/jboss/keycloak/realm-export.json
      -Dkeycloak.profile.feature.scripts=enabled
      -Dkeycloak.profile.feature.upload_scripts=enabled
    ports:
      - "8080:8080"
    depends_on:
      - database
    networks:
      - spring-cloud-network
      #- $env:COMPOSE_CONVERT_WINDOWS_PATHS=1
  • I put a double slash // at the beginning of the path

  • I use Docker Toolbox for Windows, and.... " " on commands? I get rid of them, and now works fine...

My realm-export.json file is on the source code located, along the resources folder and so on.

Lorena Gomez
  • 1,946
  • 2
  • 4
  • 11
MyProblems
  • 69
  • 1
  • 10