Hello World是一个轻量级的Docker镜像,主要用于测试和演示目的。该镜像基于Python和Flask框架构建,提供简单的HTTP服务(返回"Hello, world!"响应),可用于验证Docker部署流程、本地开发环境配置及Kubernetes服务部署等场景。本镜像在Telepresence文档及OpenShift博客中被引用,作为本地开发与容器化部署集成的示例。
python:3-alpine基础镜像,镜像体积小,资源占用低/)返回"Hello, world!"在无Docker环境时,可直接通过Python虚拟环境运行服务:
shell# 创建并激活Python虚拟环境 python3 -m venv venv source ./venv/bin/activate # Linux/macOS # 或 .\venv\Scripts\activate (Windows) # 安装依赖 pip install -qr requirements.txt # 启动服务 python3 server.py
服务启动后,控制台将输出类似以下日志,可通过http://localhost:8000访问:
* Serving Flask app "server" (lazy loading) * Environment: production WARNING: Do not use the development server in a production environment. Use a production WSGI server instead. * Debug mode: on * Running on http://0.0.0.0:8000/ (Press CTRL+C to quit)
通过以下命令构建本地Docker镜像:
shelldocker build -t datawire/hello-world .
构建过程日志示例:
Sending build context to Docker daemon 20.99kB Step 1/7 : FROM python:3-alpine ---> a93594ce93e7 Step 2/7 : WORKDIR /usr/src/app ---> Running in 99c72d9f80c6 Removing intermediate container 99c72d9f80c6 ---> ae6cf20413de Step 3/7 : EXPOSE 8000 ---> Running in 5feb111b3909 Removing intermediate container 5feb111b3909 ---> b02c0d3d44cb Step 4/7 : COPY requirements.txt . ---> f78be477ef4c Step 5/7 : RUN pip install -qr requirements.txt ---> Running in 81044c1a701a Removing intermediate container 81044c1a701a ---> f34572dbcf4a Step 6/7 : COPY server.py . ---> 49185ab473c5 Step 7/7 : CMD ["python3", "./server.py"] ---> Running in 2446171f3946 Removing intermediate container 2446171f3946 ---> 7d692d619894 Successfully built 7d692d619894 Successfully tagged datawire/hello-world:latest
4.3.1 构建镜像(见4.2节)
4.3.2 启动容器
通过docker run命令启动容器,映射本地端口8000到容器端口8000:
shelldocker run --rm -it -p 8000:8000 datawire/hello-world
--rm:容器退出后自动删除-it:交互式终端模式,便于查看日志-p 8000:8000:端口映射(本地端口:容器端口)服务启动后,可通过http://localhost:8000访问,容器日志输出与本地运行一致。
4.4.1 前提条件
kubectl并配置集群访问权限imagePullPolicy: Never)4.4.2 部署步骤
shell# 创建Deployment(部署服务)和Service(暴露访问入口) kubectl run hello-world --image=datawire/hello-world --port=8000 --expose
--image:指定镜像(需替换为实际镜像地址)--port=8000:容器端口--expose:自动创建ClusterIP类型的Service,暴露服务shell# 查看Deployment状态 kubectl get deploy -l run=hello-world # 查看Pod状态 kubectl get po -l run=hello-world # 查看Service信息(获取ClusterIP) kubectl get svc hello-world
通过临时Pod访问服务(需集群内有可执行curl的镜像,如fedora):
shellkubectl run curl-from-cluster -it --rm --image=fedora --restart=Never -- curl hello-world:8000
成功访问后,将返回Hello, world!。
shell# 获取Pod名称(替换<POD_NAME>) kubectl logs <POD_NAME>
python:3-alpine/usr/src/appEXPOSE 8000声明)["python3", "./server.py"](通过CMD指定)本镜像无额外环境变量或配置文件,主要通过运行时参数(如端口映射、镜像名称)调整部署行为,具体见4.3.2和4.4.2节。
本镜像基于Apache 2.0许可证开源,详情参见LICENSE文件。
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。



探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
无需登录使用专属域名
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
Harbor Proxy Repository 对接专属域名
Portainer Registries 加速拉取
Nexus3 Docker Proxy 内网缓存
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
docker search 限制
站内搜不到镜像
离线 save/load
插件要用 plugin install
WSL 拉取慢
安全与 digest
新手拉取配置
镜像合规机制
manifest unknown
no matching manifest(架构)
invalid tar header(解压)
TLS 证书失败
DNS 超时
域名连通性排查
410 Gone 排查
402 与流量用尽
401 认证失败
429 限流
D-Bus 凭证提示
413 与超大单层
来自真实用户的反馈,见证轩辕镜像的优质服务