[英]Docker Alpine /bin/sh apk not found
I am building a new Docker image with:我正在构建一个新的 Docker 镜像:
FROM alpine:3.4
RUN apk upgrade --update
However, its failing with the error:但是,它因错误而失败:
[INFO] /bin/sh: apk: not found
This seems to work fine on my local machine (Mac OSX) but when I try building it on a Linux CentOS 7 machine it fails.这似乎在我的本地机器 (Mac OSX) 上运行良好,但是当我尝试在 Linux CentOS 7 机器上构建它时却失败了。
I ran into something like this.我遇到了这样的事情。 It completely blew my mind, and I was questioning my sanity for a bit until I realized that
/sbin
wasn't in my container's PATH
.这完全让我大吃一惊,我一度怀疑自己的理智,直到我意识到
/sbin
不在我容器的PATH
。
# interactive session
PATH="${PATH}:/sbin"
# Dockerfile
ENV PATH="${PATH}:/sbin"
If you type command -v apk
in an interactive session in your container's base image and compare that directory with the container's $PATH
that should get you squared away.如果您在容器的基本映像中的交互式会话中键入
command -v apk
并将该目录与容器的$PATH
进行比较,这应该会让您一目了然。
If command -v apk
doesn't work for you, you could try to find
it via如果
command -v apk
对您不起作用,您可以尝试通过以下方式find
它
find / -name apk -type f -exec dirname "{}" ";"
To the best of my knowledge this is always in /sbin
.据我所知,这总是在
/sbin
。 However you get there, just ensure that the apk
binary's location is part of $PATH
无论你到达那里,只要确保
apk
二进制文件的位置是$PATH
一部分
TL;DR - If you see this error, ensure that your executable's dirname
is in your $PATH
TL;DR - 如果您看到此错误,请确保您的可执行文件的
dirname
在您的$PATH
In the end we upgraded our projects to use this Docker Maven plugin: https://github.com/fabric8io/fabric8-maven-plugin .最后我们升级了我们的项目以使用这个 Docker Maven 插件: https : //github.com/fabric8io/fabric8-maven-plugin 。 No issue thus far.
目前没有问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.