docker-alpine icon indicating copy to clipboard operation
docker-alpine copied to clipboard

docker-alpine redis how to get into bash

Open mkscala opened this issue 8 years ago • 12 comments

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 714ecf80a71b smebberson/alpine-redis "/init" 39 minutes ago Up 39 minutes 6379/tcp redis $ docker exec -it redis bash exec: "bash": executable file not found in $PATH

mkscala avatar May 08 '16 03:05 mkscala

These images don't contain Bash. They're based on Alpine Linux, but can you use docker exec -it with-contenv sh. This will give you a command line in the container with environment variables loaded.

I hope that helps. Please let me know so I can close out this issue if this has resolved your issue.

smebberson avatar May 08 '16 06:05 smebberson

Yes. You can close it. I use ash for now from alpine linux. I have few questions regarding the redis-server and redis-cli, I want one Generic Redis Server Container and then 'N' number of Redis-CLI Container(with only the redis-cli tools) I wanted only the redis-cli container to get created when i run the below docker-compose file docker-compose.yml file Original compose-file rcli: image: redis:latest links: - redis command: redis-cli -h redis

Converting to alpine linux: rcli image: smebberson/alpine-redis links:

  • redis command: redis-cli -h redis

Using Docker Network options with the link below can we achieve what am intended? https://github.com/sickp/docker-alpine-redis

I wanted to call the below compose command from the webapp, the idea is to share the redis-server container with mulitple users only via redis-cli container exposing the redis-cli in web

docker-compose run rcli

mkscala avatar May 09 '16 05:05 mkscala

Let me look into this and get back to you.

smebberson avatar May 10 '16 01:05 smebberson

any luck? regarding the cli and server redis container with cli container exposed to web and allowing the cli and redis server talking to internal private n/w

mkscala avatar May 16 '16 08:05 mkscala

you can install bash by adding to your Dockerfile: RUN apk add --update bash && rm -rf /var/cache/apk/*

fidmor89 avatar Jun 18 '16 23:06 fidmor89

If you don't want to add to the size by installing bash, you can just run /bin/sh

dondre avatar Oct 23 '16 23:10 dondre

Usually, an Alpine Linux image doesn't contain bash, Instead you can use /bin/ash, /bin/sh, ash or only sh.

docker run -it --rm alpine /bin/ash

docker run -it --rm alpine /bin/sh

docker run -it --rm alpine ash

docker run -it --rm alpine sh

--rm Automatically remove the container when it exits.

I hope this information helps you.

jansanchez avatar Apr 22 '17 20:04 jansanchez

Usually, an Alpine Linux image doesn't contain bash, Instead you can use /bin/ash, /bin/sh, ash or only sh. i.e:

docker run -it --rm alpine /bin/ash

docker run -it --rm alpine /bin/sh

docker run -it --rm alpine ash

docker run -it --rm alpine sh

I hope this information helps you.

jansanchez avatar Apr 22 '17 20:04 jansanchez

apk --update bash if you need bash for other things also, like running scripts, this command could be useful.

zakkg3 avatar Mar 08 '18 16:03 zakkg3

Just replace BASH to SH docker exec -it some-docker_app_1 sh

williaanlopes avatar Nov 10 '19 21:11 williaanlopes

docker exec -it CONTAINER_ID sh

NanheKumar avatar Jun 24 '20 13:06 NanheKumar

@jansanchez is there any difference in any of these shells?

ghost avatar Apr 13 '22 17:04 ghost