Volume bind mounting from docker in docker?

前端 未结 2 1258
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-09 07:41

I have a Docker container \"A\" that will start another container \"B\" (by volume mounting /var/run/docker.sock). Now, these containers need to share files.

Container \

2条回答
  •  -上瘾入骨i
    2021-02-09 08:17

    If you do not rely on volumes, another way to share files would be to pipe them from "A" to "B". You would need container B to handle input on STDIN, ex. with a custom entrypoint.

    In container A:

    cat some_file_on_A.txt | docker run -i container_B
    

    Example entrypoint in container B:

    while read input_from_A; do
      echo "${input_from_A}" > some_file_on_B.txt
    done
    

提交回复
热议问题