大网数据广告活动
服务器运维问答

AWS Cloud9 Building Docker Image Fail

· 52CE 我爱测

I'm quite new to networking and server management so thank you in advance for your patience. Currently I am learning how to build a docker image on AWS's Cloud9. The tutorial I'm following is from AWS themselves and is named Myth…

问题原文

原帖链接 · amx5 · CC BY-SA 4.0

I'm quite new to networking and server management so thank you in advance for your patience.

Currently I am learning how to build a docker image on AWS's Cloud9.

The tutorial I'm following is from AWS themselves and is named MythicalMysfits which is meant to walk a new user through the main tools used on AWS to build a modern web application.

I'm currently on step 2, building a dynamic website:

https://aws.amazon.com/getting-started/hands-on/build-modern-app-fargate-lambda-dynamodb-python/module-two/

When I run the following command:

docker build . -t REPLACE_ME_AWS_ACCOUNT_ID.dkr.ecr.REPLACE_ME_REGION.amazonaws.com/mythicalmysfits/service:latest

I of course replace the two parts necessary with my account ID and region.

It prompts another file Named "Dockerfile" containing the following commands to be run:

FROM ubuntu:latest
RUN echo Updating existing packages, installing and upgrading python and pip.
RUN apt-get update -y
RUN apt-get install -y python-pip python-dev build-essential
RUN pip install --upgrade pip
RUN echo Copying the Mythical Mysfits Flask service into a service directory.
COPY ./service /MythicalMysfitsService
WORKDIR /MythicalMysfitsService
RUN echo Installing Python packages listed in requirements.txt
RUN pip install -r ./requirements.txt
RUN echo Starting python and starting the Flask service...
ENTRYPOINT ["python"]
CMD ["mythicalMysfitsService.py"]

At this point the code begins to run, however fails:

Sending build context to Docker daemon  14.85kB
Step 1/13 : FROM ubuntu:latest
 ---> 1d622ef86b13
Step 2/13 : RUN echo Updating existing packages, installing and upgrading python and pip.
 ---> Using cache
 ---> d5aa972842ca
Step 3/13 : RUN apt-get update -y
 ---> Using cache
 ---> 56374a45d258
Step 4/13 : RUN apt-get install -y python-pip python-dev build-essential
 ---> Running in 3ce71d802d94
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package python-pip
The command '/bin/sh -c apt-get install -y python-pip python-dev build-essential' returned a non-zero code: 100

I understand that external to this document, apt-get does not work in Cloud9's IDE so I managed to install the python packages manually using sudo yum. I've spend a few hours over two days now trying to figure it out. I'm also in the correct directory as the tutorial advises.

Do you have any idea as to why the "Dockerfile" is misbehaving?

I thank you again for your time.

已采纳解答

原帖链接 · Régis C. · CC BY-SA 4.0

I'm also following same tutorial. I had same issue than you.

I solved it by :

  • Using python3-pip instead of python-pi
  • Using pip3 instead of pip

In Docker file you just need to change following lines:

  • Replace line 4 by:

    RUN apt-get install -y python3-pip python-dev build-essential

  • Replace line 5 by:

    RUN pip3 install --upgrade pip

  • Replace line 10 by:

    RUN pip3 install -r ./requirements.txt

  • Replace line 12 by:

    ENTRYPOINT ["python3"]

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-04-30)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。