Snowcrash
Snowcrash

Reputation: 86297

How do you shell into an Alpine/git container?

How do you shell into this image?

https://hub.docker.com/r/alpine/git

I tried:

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

but get

git: '/bin/sh' is not a git command. See 'git --help'.

Upvotes: 2

Views: 4284

Answers (2)

Jose Enrique
Jose Enrique

Reputation: 461

The solution provided by @chepner is excellent:

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

But there is another way to do it:

docker run -it --rm --entrypoint ''      alpine/git sh

This way you eliminate the entrypoint (/usr/bin/git) and run sh directly. In the end, the command executed is ENTRYPOINT + CMD, so these are the same:

  • ENTRYPOINT=['sh'] CMD=['']
  • ENTRYPOINT=[''] CMD=['sh']

So it's up to you to choose which one is more convenient.

Upvotes: 0

chepner
chepner

Reputation: 531878

You have to override the entry point (which is git). Otherwise, command line arguments are interpreted as arguments to git.

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

Upvotes: 12

Related Questions