在 ECS 上持续运行容器。

huangapple go评论61阅读模式
英文:

Keep running the container on ECS

问题

以下是您要翻译的内容:

这可能是一个非常初学者的Docker问题。

FROM nvidia/cuda:11.0.3-base-ubuntu20.04

RUN apt-get update
RUN apt-get install -y python3 python3-pip
RUN pip3 install torch torchvision

WORKDIR /work

COPY train.py /work/

ENV LIBRARY_PATH /usr/local/cuda/lib64/stubs

我从这个Dockerfile构建了Docker镜像。

现在我想在ECS上使用它。

然而,当部署完成后,这个容器停止并显示"任务中的关键容器已退出"。

我猜这是因为在这个容器上没有永久运行的进程(如服务器)?

仔细想想,当我在ECS上部署其他容器时,它有CMD命令并运行一些服务器,比如uwsgi

所以,如果我想在ECS上使用这个容器,我应该在这个容器上运行一个服务器吗?

我是正确的吗?

不过,这方面的最佳实践是什么?

英文:

This might be very beginner docker question.

FROM nvidia/cuda:11.0.3-base-ubuntu20.04

RUN apt-get update
RUN apt-get install -y python3 python3-pip
RUN pip3 install torch torchvision

WORKDIR /work

COPY train.py /work/

ENV LIBRARY_PATH /usr/local/cuda/lib64/stubs

I built docker image from this Dockerfile.

Now I want to use this on ECS.

However, when deployment finished, this container stopped with Essential container in task exited.

I guess this is because no permanent process(like server) is run on this container?

Come to think of it, when I deploy other containers on ECS it has CMD command and run some server such as uwsgi.

So, If I want to use this container on ECS, I should run a server on this container?

Am I correct?

However what is the best practice for it?

答案1

得分: 0

似乎您想在您的ECS上运行Python模型。
将以下内容添加到您的Dockerfile应该能够在ECS上运行您的Python文件。
但是,我认为您需要在脚本内部设置逻辑,以便它可以在不同的时间间隔运行,或者如果您希望在特定时间运行,可以添加cron配置。

英文:

It looks like you want to run your Python model on your ECS.
Adding

CMD ["py","train.py"]

to your Dockerfile should be able to run your Python file on ECS.
However, I think you need to set up logic inside your script to make it run at different intervals or add a cron configuration if you want it to run at specific time.

huangapple
  • 本文由 发表于 2023年6月5日 00:13:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/76401322.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定