Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将curl(或类似软件)与;docker run“;是否已使用入口点?_Docker_Curl_Aiohttp - Fatal编程技术网

如何将curl(或类似软件)与;docker run“;是否已使用入口点?

如何将curl(或类似软件)与;docker run“;是否已使用入口点?,docker,curl,aiohttp,Docker,Curl,Aiohttp,我想用Tor/aiohttp服务器创建docker映像,用作HTTP请求的代理(curl)。我已经准备好了Docker工作图像(我可以使用外部curl-x),这是语法的主要问题 我需要什么:我需要像使用docker run test\u image curl api.ipify.org那样使用这个图像。主要问题-我不明白如何正确配置ENTRYPOINT/CMD。我使用supervisor激活服务(tor/aiohttp),因此Docker映像的最后一行是: ENTRYPOINT[“/usr/bi

我想用
Tor
/
aiohttp
服务器创建docker映像,用作HTTP请求的代理(
curl
)。我已经准备好了Docker工作图像(我可以使用外部
curl-x
),这是语法的主要问题

我需要什么:我需要像使用docker run test\u image curl api.ipify.org那样使用这个图像。主要问题-我不明白如何正确配置ENTRYPOINT/CMD。我使用
supervisor
激活服务(tor/aiohttp),因此Docker映像的最后一行是:

ENTRYPOINT[“/usr/bin/supervisords”、“-c”、“/etc/supervisor/conf.d/supervisords.conf”]

问题:如何配置Docker映像(使用ENTRYPOINT/CMD),以便映像在激活服务后运行curl请求

对于当前exec入口点(或shell形式),它忽略curl。若我使用cmd而不是entrypoint,curl可以工作,但image忽略cmd,所以服务不会被激活


因此,需要关于Docker逻辑/语法的任何建议,以便我可以使其正常工作。

您可以将ENTRYPOINT作为shell脚本而不是命令运行:

docker-entrpoint.sh

#!/bin/bash
set -e

/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
curl api.ipify.org
Dockerfile

FROM debian:stretch
...
COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
ENTRYPOINT ["docker-entrypoint.sh"]

您可以将入口点作为shell脚本而不是命令运行:

docker-entrpoint.sh

#!/bin/bash
set -e

/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
curl api.ipify.org
Dockerfile

FROM debian:stretch
...
COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
ENTRYPOINT ["docker-entrypoint.sh"]

为什么从容器中运行curl很重要?为什么容器运行多个服务很重要?这是一项具有直接条件的学术任务。我对curl或运行服务没有问题,主要问题是-如何将ENTRYPOINT与一些外部软件(curl、ping或tracert等)结合起来。为什么从容器中运行curl很重要?为什么容器运行多个服务很重要?这是一项具有直接条件的学术任务。我对curl或运行服务没有问题,主要问题是-如何将ENTRYPOINT与一些外部软件(curl、ping或tracert等)结合起来。它可以工作,但我需要使用“docker run”中的curl,以便我可以从CLI中指定url等。当然,我可以使用env变量,但由于条件的原因,需要使用“docker run test_image curl”中的curl(或其他软件)。您可以在运行时覆盖入口点,但我们开始打破一些docker原则:
docker run--rm-it--ENTRYPOINT”curlhttp://google.com"test_image
docker运行test_image'curl someurl.com'-没有用你可以在运行时覆盖入口点-我可以,但我仍然需要在使用curl之前启动服务,这样它就可以使用服务套接字作为代理。不需要使用容器运行curl,curl在一个新行上,当时我认为它在同一行:)它可以工作,但我需要从“docker run”,因此我可以从CLI中指定url等。当然,我可以使用env变量,但由于条件的原因,需要使用“docker run test_image curl”中的curl(或其他软件)。您可以在运行时覆盖入口点,但我们开始破坏一些docker主体:
docker run--rm-it--ENTRYPOINT”卷曲http://google.com“test_image
docker运行test_image'curl someurl.com'-没有用您可以在运行时覆盖入口点-我可以,但我仍然需要在使用curl之前启动服务,这样它就可以使用服务套接字作为代理。无需使用容器运行curl,curl位于新行,当时我认为它位于同一行:)