Home > Back-end >  Create folder outside the container in the host machine
Create folder outside the container in the host machine

Time:03-23

I want to change the folder to which the config-server downloads files from git.

when I do it locally in windows, it works perfectly fine, and I can find the created folder.

but when I deploy the config-server to docker, I can't find the folder in the path I chose

this is my properties config

  cloud:
    config:
      server:
        git:
          uri: "https://bitbucket.org/xxx/remote-config.git"
          username: "xxx"
          password: "xxx"
          basedir: "${CONFIG_LOCAL_REPO_DIR}"
          default-label: "master"
          clone-on-start: true
          force-pull: true

and this is my docker-compose file

version: '3.8'

services:

  config-server:
    image: "config-server:1.0"
    build: "./config-server"
    container_name: "config_server"
    restart: "always"
    networks:
      - "network"
    volumes:
      - "myvolume"
    depends_on:
      - "rabbitmq"
    environment:
      CONFIG_LOCAL_REPO_DIR: "myvolume:/home/debian/backend-app/local-repo"


volumes:
  myvolume:

networks:
  network:

how can I solve this to create in my machine the folder I have chosen?

CodePudding user response:

If you want the data to easily accessible on the host system, i.e. in the same dir as the compose file, use a bind mount.

services:
  config-server:
    volumes:
      - ./local-repo:/myrepo
    environment:
      CONFIG_LOCAL_REPO_DIR: /myrepo

Note, this is not referencing a volume from the volumes: key in the YAML file, but a path on the host system. In this case, relative to the compose file.

  • Related