【问题标题】:call a script file from one docker container to another container using --link container使用 --link 容器将脚本文件从一个 docker 容器调用到另一个容器
【发布时间】:2016-07-27 11:43:24
【问题描述】:

我使用 docker 命令 docker run -d -name tensorflow_syntaxnet_container syntaxnet_image 创建了一个名为“tensorflow-syntaxnet_container”的容器,另一个容器“python_flask”使用 docker 命令 docker run -d -p 0.0.0.0:5001:5001 --link tensorflow-syntaxnet_container:syntaxnet -name python_flask python_image:latest 链接了 tensorflow-syntaxnet_container,并且两个容器都成功创建并且它按预期单独工作。

还验证了 python_flask 容器内衬了 syntaxnet 容器作为 cat /etc/hosts 结果 172.17.0.27 syntaxnet e002ab9f43a7 tensorflow-syntaxnet_container 这是 syntaxnet 容器的容器 ip。

我需要调用一个脚本文件 demo.sh 并需要从我位于 python_flask container 的 python 烧瓶应用程序访问 connect with tensorflow-syntaxnet_container 中的输出文件

我找不到链接容器tensorflow-syntaxnet_container的任何挂载目录或文件夹

谁能帮我弄清楚如何调用脚本文件并从一个容器访问所有文件到另一个容器

【问题讨论】:

    标签: linux docker containers tensorflow syntaxnet


    【解决方案1】:

    在这里查看Docker Link Docks 在这里Docker Volume Docs

    --link 只能链接容器的网络接口。如果你想共享文件系统,你可能需要--volumes-from。

    docker create -v /path/to/script/dir --name scriptstore image1:name
    docker run -d --volumes-from scriptstore --name runner image2:name bash /path/to/script/dir/scriptname.sh
    

    【讨论】:

      【解决方案2】:

      链接两个容器可以实现网络通信。你想要的是卷:https://docs.docker.com/engine/tutorials/dockervolumes/#/creating-and-mounting-a-data-volume-container

      【讨论】:

        猜你喜欢
        • 2016-06-20
        • 1970-01-01
        • 1970-01-01
        • 2018-09-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-01-24
        • 1970-01-01
        相关资源
        最近更新 更多