docker进入容器无法使用bash

进入容器命令:

docker exec -it google-authenticator bash

报错详情:

OCI runtime exec failed: exec failed: unable to start container process: exec: "bash": executable file not found in $PATH: unknown

解决办法:
Dockerfile文件中添加:

RUN apk add --no-cache bash

删除原来的镜像,重新构建并启动即可

示例:
Dockerfile文件内容

FROM openjdk:8-jdk-alpine
RUN apk add --update --no-cache ttf-dejavu fontconfig && rm -rf /var/cache/apk/*
RUN apk add --no-cache bash
COPY google-authenticator-demo-0.0.1-SNAPSHOT.jar /app.jar
ENV JAVA_OPTS="-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom"
ENTRYPOINT ["/bin/bash", "-c", "java -Duser.timezone=GMT+08 -jar /app.jar"]

构建镜像:

docker build -t google-authenticator .

运行:

docker run -itd --name google-authenticator -p 8111:8111 google-authenticator

正常进入容器

[root@hecs-399223 docker_service]# docker exec -it google-authenticator bash
bash-4.4# 

猜你喜欢

转载自blog.csdn.net/LSW1737554365/article/details/134507728