skip to Main Content

I have this docker-compose:

version: "3.9"

services:
  myserver:
    image: <some image>
    restart: always
    volumes:
      - ./res:/tmp/configs
      - ./myfolder:/tmp/logs

Should I expect to see the files that are in /tmp/logs inside the container, in the host folder ‘myfolder’?
‘myfolder’ is empty and I want it to be updated with the contents of the /tmp/logs folder in the container.

2

Answers


  1. Chosen as BEST ANSWER

    What worked for me is using full path for the host path.

    C:myfolder for example.


  2. For formatting purposes, I post this as an answer instead of comment.

    Can you put following in test.sh on the host?

    #!/usr/bin/env bash
    
    testdir=/tmp/docker-compose
    
    rm -rf "$testdir"; mkdir -p "$testdir"/{myfolder,res}
    cd "$testdir"
    
    cat << EOF > docker-compose.yml
    version: "3.9"
    
    services:
      myserver:
        image: debian
        restart: always
        volumes:
          - ./res:/tmp/configs
          - ./myfolder:/tmp/logs
        command: sleep inf
    EOF
    
    docker-compose up
    

    and run bash test.sh on the host and see if it works. host dir is /tmp/docker-compose/myfolder.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search