Mount a volume in docker-compose. How is it done?

前端 未结 1 1156
温柔的废话
温柔的废话 2020-12-30 01:04

If I execute this cmd in a console:

 docker run -it --rm --link rabbit --link elasticsearch -v \"$PWD\"/logstash:/config-dir logstash logstash -f /config-dir         


        
相关标签:
1条回答
  • 2020-12-30 01:33

    Your config is probably not working because your version of docker-compose does not execute shell expansions while creating your container. That means that docker compose is trying to find a literal path $PWD/logstash instead of expanding $PWD to your present directory. Later versions of docker compose do allow for environment variable expansion.

    Docker-compose does allow relative paths though, through the use of ./, which references the folder the compose file is in, not necessarily your pwd, so you just need to change your compose file to be:

    volumes:
        - ./logstash:/config_dir
    
    0 讨论(0)
提交回复
热议问题