当环境从蟒蛇建成功建成码头工人形象不运行

问题描述 投票:0回答:1

我用下面Dockerfile建成了码头工人的图像:

FROM continuumio/miniconda3

ENTRYPOINT [ “/bin/bash”, “-c” ]

ADD angular_restplus.yaml angular_restplus.yaml

RUN ["conda", "env", "create", "-f", "angular_restplus.yaml"]

RUN ["/bin/bash", "-c", "source activate work"]

COPY json_to_db.py json_to_db.py

CMD ["gunicorn", "-b", "0.0.0.0:3000", "json_to_db:app"]

并命令来构建它:

sudo docker build -t testimage:latest .

贯穿始终:

Step 5/7 : RUN ["/bin/bash", "-c", "source activate work"]
 ---> Running in 45c6492b1c67
Removing intermediate container 45c6492b1c67
 ---> 5b5604dc281d
Step 6/7 : COPY json_to_db.py json_to_db.py
 ---> e5d05858bed1
Step 7/7 : CMD ["gunicorn", "-b", "0.0.0.0:3000", "json_to_db:app"]
 ---> Running in 3ada6fd24d09
Removing intermediate container 3ada6fd24d09
 ---> 6ed934acb671
Successfully built 6ed934acb671
Successfully tagged testimage:latest

然而,当我现在尝试使用它,它不工作;我试过了:

sudo docker run --name testimage -d -p 8000:3000 --rm testimage:latest

这似乎是因为它打印好工作

b963bdf97b01541ec93e1eb7

不过,我不能在我的浏览器,通过访问服务

sudo docker ps -a

仅示出了从上面创建图像所需的中间容器。

当我尝试没有-d标志运行它,我得到

gunicorn: 1: [: “/bin/bash”,: unexpected operator

这是否意味着我不得不再次改变ENTRYPOINT?如果是这样,是什么?

docker anaconda dockerfile
1个回答
1
投票

该解决方案可在以下post找到。我只好用

"/bin/bash", "-c"

整个部分。以下(也使用@larsks'输入谁同时删除他的回答)现在的工作罚款:

FROM continuumio/miniconda3

COPY angular_restplus.yaml angular_restplus.yaml
SHELL ["/bin/bash", "-c"] 
RUN ["conda", "env", "create", "-f", "angular_restplus.yaml"]
COPY json_to_db.py json_to_db.py
CMD source activate work; gunicorn -b 0.0.0.0:3000 json_to_db:app

然后一个可以运行

docker build -t testimage:latest .

最后

docker run --name testimage -d -p 3000:3000 --rm testimage:latest

如果现在使用

docker ps -a

一个会得到预期的结果:

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
61df8ac0432c        testimage:latest    "/usr/bin/tini -- /b…"   16 seconds ago      Up 15 seconds       0.0.0.0:3000->3000/tcp   testimage

然后,可以访问该服务在

http://localhost:3000/
© www.soinside.com 2019 - 2024. All rights reserved.