bash - Adding bash binary to a "scratch" docker image
问题描述
I am trying to add bash to a "FROM Scratch" docker image.
I've copied a bash binary from the official bash docker image from docker hub (https://hub.docker.com/_/bash)
docker run -d bash:latest sleep 100
docker cp "$bash_container_id":/usr/local/bin/bash .
My Dockerfile is as follows
FROM jaegertracing/all-in-one:latest
COPY bin/bash /bin
ENV PATH "$PATH:bin/bash"
RUN ["bash"]
Which, when building, results in
Sending build context to Docker daemon 5.213MB
Step 1/4 : FROM jaegertracing/all-in-one:latest
latest: Pulling from jaegertracing/all-in-one
023a144cdcf7: Already exists
d247ed88ca7d: Already exists
dc4682d67823: Already exists
Status: Downloaded newer image for jaegertracing/all-in-one:latest
---> b64ba73d1fa4
Step 2/4 : COPY bin/bash /bin
---> b6e8ae824d24
Step 3/4 : ENV PATH "$PATH:bin/bash"
---> Running in eda2042dff57
Removing intermediate container eda2042dff57
---> f1288ded6fcf
Step 4/4 : RUN ["bash"]
---> Running in 616c80b0cb8c
OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"bash\": executable file not found in $PATH": unknown
the jaegertracing/all-in-one
image is using a "Scratch" base image that contains nothing (no sh, no bash, etc)
I am trying to add bash to it for debugging reasons.
Any suggestions? Thanks in advance
解决方案
你没有$PATH
正确配置你的。路径是在其中查找可执行文件的一系列目录,而不是可执行文件本身的路径。此外,由于您要迁移bin/bash
到/bin/bash
,因此您不必担心添加bin/bash
到路径中。但无论哪种方式,你想要的是
ENV PATH "$PATH:bin"
ENV PATH "$PATH:/bin"
我相信您想要的是选项#2,因为它是您将 bash 复制到的地方。
推荐阅读
- sql - SQL 性能对约束或唯一索引中的多个列的影响
- vb.net - VB.NET 数据库不在 MS Access 和登录错误
- python - 解析 HTML——为什么这个文档必须用文本而不是标签来解析?
- r - 使用 effsize 包中的 cohen.d 函数时出错(“row.names”长度无效)
- python - /api/register/ 'module' 对象的 TypeError 不可调用
- kubernetes - AKS 群集创建失败并出现错误“安全规则具有无效的端口范围”
- xamarin.forms - 图片太大
- github-pages - 从新创建的 github 页面获取 304 响应
- node.js - Keycloak:使用 keycloak-admin 为用户生成访问令牌
- node.js - err_http_headers_sent]:在从服务器获取电子邮件时,无法在将标头发送到客户端后设置标头