简体   繁体   English

Docker 构建挂起

[英]Docker build hangs

I am trying to build a Docker Img for a python program(It's a telegram Bot from FreeCodeCamp ), Now the code runs perfectly but when I try to build this Dockerfile我正在尝试为 python 程序构建 Docker Img(它是来自FreeCodeCamp的电报 Bot),现在代码运行完美,但是当我尝试构建这个 Z3254677A7917C6C01F55212F8C6

FROM python:3.6
COPY . /app

WORKDIR /app

RUN pip install -r requirement.txt

ENV PORT 8080

ENV HOST 0.0.0.0

RUN ["python","bot.py"]

The system hangs.系统挂起。

dishant_sonawane17@cloudshell:~/project (voice-261819)$ docker build -t python-docker-dev .
Sending build context to Docker daemon  4.608kB
Step 1/7 : FROM python:3.6
 ---> e0373ff33a19
Step 2/7 : COPY . /app
 ---> Using cache
 ---> 6f9396ff2a64
Step 3/7 : WORKDIR /app
 ---> Using cache
 ---> 1c216f1a529c
Step 4/7 : RUN pip install -r requirement.txt
 ---> Using cache
 ---> 531e40ac101d
Step 5/7 : ENV PORT 8080
 ---> Using cache
 ---> 385b36f30518
Step 6/7 : ENV HOST 0.0.0.0
 ---> Using cache
 ---> b1ba2f0bf26e
Step 7/7 : RUN ["python","bot.py"]
 ---> Running in 5ceec7069ee9

Not sure what your bot.py will do, but it will run and wait to finish... It looks like you want bot.py to be the application to start once the container is started.不确定你的bot.py会做什么,但它会运行并等待完成......看起来你希望bot.py成为容器启动后启动的应用程序。

You should use ENTRYPOINT or CMD for this.为此,您应该使用ENTRYPOINTCMD

In a nutshell:简而言之:

  • RUN executes command(s) in a new layer and creates a new image. RUN在新层中执行命令并创建新图像。 Eg, it is often used for installing software packages.例如,它通常用于安装软件包。
  • CMD sets default command and/or parameters, which can be overwritten from command line when docker container runs. CMD设置默认命令和/或参数,可以在 docker 容器运行时从命令行覆盖。
  • ENTRYPOINT configures a container that will run as an executable. ENTRYPOINT配置将作为可执行文件运行的容器。

More detailed explanation/source: https://goinbigdata.com/docker-run-vs-cmd-vs-entrypoint/ .更详细的解释/来源: https://goinbigdata.com/docker-run-vs-cmd-vs-entrypoint/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM