[英]Can't use curl inside a docker container that has installed it before
我正在使用 RestHeart docker 图像。
从它的dockerfile :
FROM openjdk:8u111-jre-alpine
RUN apk upgrade --update && apk add --update libstdc++ curl ca-certificates bash
...
这意味着当前安装了 curl,对吧?
我在 Docker 中运行该图像,组成:
version: '3.4'
services:
mongodb:
image: mongo:4.0
ports:
- 27017:27017
restheart:
image: softinstigate/restheart:3.10.0
ports:
- 8082:8080
volumes:
- ./restheart:/opt/restheart/etc:ro
depends_on:
- mongodb
restheart 容器的容器 id 是e1a023d9a8a9
。
但是当我执行docker exec e1a023d9a8a9 curl
我得到:
OCI 运行时执行失败:执行失败:container_linux.go:346:启动容器进程导致“exec:\”curl\”:$PATH 中找不到可执行文件”:未知
那个 Dockerfile 已经过时了,我不知道为什么 Docker Hub 还在发布那个,它至少有两年的历史了!
最新的一个在https://github.com/SoftInstigate/restheart/blob/master/core/Dockerfile
适用于 RESTHeart v5
由于基础映像是 gcr.io/distroless/java:11,因此它甚至不包含 sh shell。
顺便说一句,如果有人能告诉我如何更新 Dockerfile 会很有帮助,我在 Docker 集线器仪表板中找不到任何链接。
从 RESTHeart 5.0.1 开始,我们决定将 Docker 基础镜像移至adoptopenjdk:11-jre-hotspot-bionic
。 请参阅新的Dockerfile 。
softinstigate/restheart
图像的最新和5.0.1标签现在都基于 Ubuntu 18.04 LTS 发行版。
distroless 镜像仍然构建(参见distroless.Dockerfile )并上传到 Docker Hub,但它被标记为distroless
和5.0.1-distroless
以区别于默认镜像。
发行说明: https://github.com/SoftInstigate/restheart/releases/tag/5.0.1
Docker 集线器: https://hub.docker.com/repository/docker/softinstigate/restheart
我注意到distroless
在他们的最新图像中使用了 distroless。 但我不明白为什么它不允许在使用exec
的旧图像中执行。 即使入口点覆盖也没有运气。
$ docker run -it --entrypoint=/bin/bash softinstigate/restheart:3.10.0 -c curl
docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory": unknown.
ERRO[0000] error waiting for container: context canceled
但是我在本地构建并且它可以工作。
$ git clone https://github.com/SoftInstigate/restheart.git
$ git checkout tags/4.0.0
标签3.10.0
在 repo 中不可用。
$ cd restheart/Docker
$ docker build --build-arg RELEASE=3.10.0 -t harik8/restheart:latest .
$ docker run -it --entrypoint=/bin/bash harik8/restheart:latest -c curl
curl: try 'curl --help' or 'curl --manual' for more information
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.