简体   繁体   English

不能在之前安装过的 docker 容器中使用 curl

[英]Can't use curl inside a docker container that has installed it before

I'm using RestHeart docker image.我正在使用 RestHeart docker 图像。

From it's dockerfile :从它的dockerfile

FROM openjdk:8u111-jre-alpine

RUN apk upgrade --update && apk add --update libstdc++ curl ca-certificates bash

...

This means that curl is currently installed, right?这意味着当前安装了 curl,对吧?

I run that image inside a Docker compose:我在 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

The container id for restheart container is e1a023d9a8a9 . restheart 容器的容器 id 是e1a023d9a8a9

But when I execute docker exec e1a023d9a8a9 curl I get:但是当我执行docker exec e1a023d9a8a9 curl我得到:

OCI runtime exec failed: exec failed: container_linux.go:346: starting container process caused "exec: \"curl\": executable file not found in $PATH": unknown OCI 运行时执行失败:执行失败:container_linux.go:346:启动容器进程导致“exec:\”curl\”:$PATH 中找不到可执行文件”:未知

That Dockerfile is obsolete and I don't know why Docker Hub is still publishing that one, it's at least two years old!那个 Dockerfile 已经过时了,我不知道为什么 Docker Hub 还在发布那个,它至少有两年的历史了!

The latest one is at https://github.com/SoftInstigate/restheart/blob/master/core/Dockerfile最新的一个在https://github.com/SoftInstigate/restheart/blob/master/core/Dockerfile

It's for RESTHeart v5适用于 RESTHeart v5

As the base image is gcr.io/distroless/java:11 then it does not contain even the sh shell.由于基础映像是 gcr.io/distroless/java:11,因此它甚至不包含 sh shell。

By the way, if someone could tell me how to update that Dockerfile that would be very helpful, I can't find any link in the Docker Hub dashboard.顺便说一句,如果有人能告诉我如何更新 Dockerfile 会很有帮助,我在 Docker 集线器仪表板中找不到任何链接。


UPDATE (24th may 2020)更新(2020 年 5 月 24 日)

Starting from RESTHeart 5.0.1 we have decide to move the Docker base image to adoptopenjdk:11-jre-hotspot-bionic .从 RESTHeart 5.0.1 开始,我们决定将 Docker 基础镜像移至adoptopenjdk:11-jre-hotspot-bionic See the new Dockerfile .请参阅新的Dockerfile

Both the latest and 5.0.1 tags of softinstigate/restheart images are now based on the Ubuntu 18.04 LTS distribution. softinstigate/restheart图像的最新5.0.1标签现在都基于 Ubuntu 18.04 LTS 发行版。

The distroless image is still built (see distroless.Dockerfile ) and uploaded to Docker Hub, but it is tagged as distroless and 5.0.1-distroless to distinguish it from the default image. distroless 镜像仍然构建(参见distroless.Dockerfile )并上传到 Docker Hub,但它被标记为distroless5.0.1-distroless以区别于默认镜像。

Release notes: https://github.com/SoftInstigate/restheart/releases/tag/5.0.1发行说明: https://github.com/SoftInstigate/restheart/releases/tag/5.0.1

Docker hub: https://hub.docker.com/repository/docker/softinstigate/restheart Docker 集线器: https://hub.docker.com/repository/docker/softinstigate/restheart

I noticed restheart is using distroless in their latest images.我注意到distroless在他们的最新图像中使用了 distroless。 But I couldn't figure out why it's not allowing to exec in older images which are using alpine.但我不明白为什么它不允许在使用exec的旧图像中执行。 Even no luck with entrypoint overriding.即使入口点覆盖也没有运气。

    $ 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 

But I built locally and it works.但是我在本地构建并且它可以工作。

$ git clone https://github.com/SoftInstigate/restheart.git
$ git checkout tags/4.0.0

The tag 3.10.0 is not available at the repo.标签3.10.0在 repo 中不可用。

$ cd restheart/Docker

Add Dockerfile添加Dockerfile

$ 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM