[英]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.