【发布时间】: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