How to merge host folder with container folder in Docker?

前端 未结 1 1337
醉酒成梦
醉酒成梦 2021-01-07 23:48

I have Wikimedia running on Docker. Wikimedia\'s extensions reside in extensions/ folder which initially contain built-in extensions (one extensions = one subfo

1条回答
  •  执笔经年
    2021-01-08 00:27

    You can mount a volume from your host to a separate location than the extension folder, then in your startup script, you can copy the contents to the container's directory. You will need to rebuild your host once.

    For example:

    Dockerfile:
      RUN cp startup-script /usr/local/bin/startup-script
      CMD /usr/local/bin/startup-script
    
    startup-script:
       #!/bin/bash
       cp /mnt/extensions /path/to/wikipedia/extensions
       /path/to/old-startup-script $@
    
    docker run -d -v /home/admin/wikimedia/extensions:/mnt/extensions wikipedia
    

    That is one way to get around this problem, the other way would be to maintain a separate data container for extensions, then you will mount this and maintain it outside of the wikipedia container. It would have to have all the extensions in it.

    You can start one like so:

     docker run -d -v /home/admin/wikimedia/extensions:/path/to/wikipedia/extensions --name extensions busybox tail -f /dev/null
     docker run -d --volumes-from extensions wikipedia
    

    0 讨论(0)
提交回复
热议问题