【问题标题】:Entrypoint not found when deployed to Fargate. Locally works部署到 Fargate 时找不到入口点。本地工作
【发布时间】:2023-03-19 17:30:02
【问题描述】:

我有以下 Dockerfile,目前在我的设备上本地工作:

FROM python:3.7-slim-buster

WORKDIR /app

COPY . /app

VOLUME /app

RUN chmod +x /app/cat/sitemap_download.py

COPY entrypoint.sh /app/entrypoint.sh

RUN chmod +x /app/entrypoint.sh

ARG VERSION=3.7.4

RUN apt update && \
       apt install -y bash wget && \
       wget -O /tmp/nordrepo.deb https://repo.nordvpn.com/deb/nordvpn/debian/pool/main/nordvpn-release_1.0.0_all.deb && \
       apt install -y /tmp/nordrepo.deb && \
       apt update && \
       apt install -y nordvpn=$VERSION && \
       apt remove -y wget nordvpn-release

RUN apt-get clean \
    && apt-get -y update
RUN apt-get -y install python3-dev \
    python3-psycopg2 \
    && apt-get -y install build-essential

RUN pip install --upgrade pip

RUN pip install -r cat/requirements.txt

RUN pip install awscli

ENTRYPOINT ["sh", "-c", "./entrypoint.sh"]

但是当我将它部署到 Fargate 时,容器在达到稳定状态之前停止:

sh: 1: ./entrypoint.sh: 未找到

编辑:添加 entrypoint.sh 文件以进行说明:

#!/bin/env sh
# start process, but it should exit once the file is in S3
/app/cat/sitemap_download.py
# Once the process is done, we are good to scale down the service
aws ecs update-service --cluster cluster_name --region eu-west-1 --service service-name --desired-count 0

我尝试修改 ENTRYPOINT 以将其用作 exec 表单,或使用完整路径,但总是遇到同样的问题。关于我做错了什么有什么想法吗?

【问题讨论】:

  • 不是你的意思,对不起。 entrypoint.sh 是 docker 容器中的一个脚本,在容器启动时运行。例如,如果我使用 python 脚本 (ENTRYPOINT/app/cat/sitemap_download.py) 找到脚本并启动容器。
  • 你尝试过简单地写ENTRYPOINT ["/app/entrypoint.sh"]吗?
  • 是的,如帖子中所述尝试完整路径返回相同的问题。在本地工作,但不能在 Fargate 上工作。
  • 如果它在本地工作,那么你创建和启动容器的方式有问题。
  • 你是如何在本地运行它的? (我怀疑VOLUME 行引起了问题,您可以将其删除,但我不确定它是否会在本地运行。)

标签: docker aws-fargate


【解决方案1】:

我现在已经设法解决了。

将 Dockerfile 更改为如下所示可以解决问题:

COPY . /app

VOLUME /app

RUN chmod +x /app/cat/sitemap_download.py

COPY entrypoint.sh /app/entrypoint.sh

RUN chmod +x /app/entrypoint.sh

ARG VERSION=3.7.4

RUN apt update && \
       apt install -y bash wget && \
       wget -O /tmp/nordrepo.deb https://repo.nordvpn.com/deb/nordvpn/debian/pool/main/nordvpn-release_1.0.0_all.deb && \
       apt install -y /tmp/nordrepo.deb && \
       apt update && \
       apt install -y nordvpn=$VERSION && \
       apt remove -y wget nordvpn-release

RUN apt-get clean \
    && apt-get -y update
RUN apt-get -y install python3-dev \
    python3-psycopg2 \
    && apt-get -y install build-essential

RUN pip install --upgrade pip

RUN pip install -r cat/requirements.txt

RUN pip install awscli

ENTRYPOINT ["/bin/bash"]
CMD ["./entrypoint.sh"]

我在阅读后尝试了这个:What is the difference between CMD and ENTRYPOINT in a Dockerfile?

我相信这个语法可以解决这个问题,因为我通过入口点指示 bash 在启动时运行,然后将脚本作为参数传递。

【讨论】:

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