简体   繁体   中英

How to get into Docker container's shell when bash is not available?

HI recently downloaded mcandre/docker-java-slim and is trying to install a few java apps however I can't get into bash? I think may be its not even installed.

 docker run -it --rm \
-v /home/ubuntu:/data --name test mcandre/docker-java-slim bash

the above command fails? Is there anything else I can do? thanks!

bash is not installed on this image but sh is so just do docker run -it --rm -v /home/ubuntu:/data --name test mcandre/docker-java-slim sh

Since the base OS is Linux Alpine, it does not come with bash , but you can use either sh or ash .

Up to my knowledge, sh is pre-installed on the most of Linux Distros, so you can use sh as shell whenever you get fail with running bash .

Run either:

docker run -it --rm \
-v /home/ubuntu:/data --name test mcandre/docker-java-slim sh

or:

docker run -it --rm \
-v /home/ubuntu:/data --name test mcandre/docker-java-slim ash

to log in with shell.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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