Ahdee
Ahdee

Reputation: 4949

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!

Upvotes: 1

Views: 1072

Answers (2)

Saeed
Saeed

Reputation: 4115

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.

Upvotes: 1

welcomeboredom
welcomeboredom

Reputation: 635

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

Upvotes: 1

Related Questions