Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker-alpine redis how to get into bash #43

Open
mkscala opened this issue May 8, 2016 · 12 comments
Open

docker-alpine redis how to get into bash #43

mkscala opened this issue May 8, 2016 · 12 comments

Comments

@mkscala
Copy link

mkscala commented May 8, 2016

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

@smebberson
Copy link
Owner

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.

@mkscala
Copy link
Author

mkscala commented May 9, 2016

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

@smebberson
Copy link
Owner

Let me look into this and get back to you.

@mkscala
Copy link
Author

mkscala commented May 16, 2016

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

@fidmor89
Copy link

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

@dondre
Copy link

dondre commented Oct 23, 2016

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

@jansanchez
Copy link

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
Copy link

jansanchez commented Apr 22, 2017

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.

@zakkg3
Copy link

zakkg3 commented Mar 8, 2018

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

@williaanlopes
Copy link

williaanlopes commented Nov 10, 2019

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

@NanheKumar
Copy link

docker exec -it CONTAINER_ID sh

@ghost
Copy link

ghost commented Apr 13, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants