本文介绍了如何在基于Alpine的Docker映像中使用bash?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从openjdk:8-jdk-alpine创建了一个docker镜像,但是当我尝试执行简单的命令时,出现以下错误:

I created a docker image from openjdk:8-jdk-alpine but when I try to execute simple commands I get the following errors:

RUN bash
/bin/sh: bash: not found

RUN ./gradlew build
env: can't execute 'bash': No such file or directory


推荐答案

Alpine docker image没有安装bash默认。您将需要添加以下命令来获取 bash

Alpine docker image doesn't have bash installed by default. You will need to add following commands to get bash:

RUN apk update && apk add bash

如果您使用 Alpine 3.3 + 然后您就可以这样做

If youre using Alpine 3.3+ then you can just do

RUN apk add --no-cache bash

使docker映像尺寸较小。 (感谢@sprkysnrky的评论)

to keep docker image size small. (Thanks to comment from @sprkysnrky)

这篇关于如何在基于Alpine的Docker映像中使用bash?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 20:26