Google云平台基础实验:CoreOS构建Docker镜像报错求助
Hey there, let's tackle your issues one by one—this is a pretty common problem with older Docker configurations, so we can get this sorted out quickly.
1. Is the tutorial outdated? Where to find the latest version?
Yes, it looks like the tutorial (and the associated code repo) is outdated. The key clue here is the attempt to use HTTP for PyPI, which has been deprecated for years.
For up-to-date Google Cloud Platform Fundamentals training, you’ll want to use Google’s official learning resources. These are maintained regularly to align with current GCP services and best practices—you can access them directly through the Google Cloud Learning Center (no external links needed; just search for it within Google Cloud’s official documentation portal).
2. What’s causing the error?
Your guess about pip/Python not being installed is off the mark—docker build does execute the installation steps defined in your Dockerfile, but the issue lies elsewhere:
- PyPI no longer supports HTTP: Back in 2018, PyPI disabled unencrypted HTTP access entirely. The error message shows pip is trying to fetch from
http://pypi.python.org/simple/, which is no longer accessible. - Missing pip log: The
/root/.pip/pip.logfile doesn’t exist because Docker containers are ephemeral by default. When the build fails, the temporary container used for that build step is discarded, so you can’t access files inside it unless you explicitly keep the container or modify the build process to persist logs.
3. How to fix this?
Here are concrete steps to resolve the build failure:
- Update the PyPI source in your Dockerfile: Modify any
pip installcommands to use HTTPS. For example, replace:
with:RUN pip install flask
TheRUN pip install --upgrade pip && pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org flask--trusted-hostflags ensure pip trusts the HTTPS endpoints, and upgrading pip first ensures you’re using a version that properly handles HTTPS. - Use an updated base image: Check the
FROMline in your Dockerfile. If it’s using an old Python or CoreOS image (likepython:2.7or a legacy CoreOS variant), switch to a newer, maintained version. For example,python:3.10-slimis a lightweight, up-to-date base that uses HTTPS for PyPI by default. - Adjust the repo’s Dockerfile specifically: For the
cp100-cloud-sql-pythonrepo, open the Dockerfile and make the above changes. If the file usesapt-getto install Python/pip, ensure those packages are up-to-date before runningpip install.
Once you make these changes, re-run your docker build command—it should successfully fetch the Flask dependency and complete the build.
内容的提问来源于stack exchange,提问作者Maxime Van Goethem

