I have a base image I cannot modify in this case. The entrypoint of the image is python3, but I have a docker run in which I would like to make /bin/bash the entrypoint. The point is, I want to put the -c and -l flags in the /bin/bash command.
To clarify, I would like the equivalent of
ENTRYPOINT ["/bin/bash", "-l", "-c"]
but when I run the docker run --entrypoint /bin/bash <image>
command
2
Answers
If you can’t extend the image, you can achieve that by setting
/bin/bash
as the entrypoint and then passing the rest of the arguments as arguments to the container.E.G:
Runs
ls
inside your container.docker run
does not accept sentences surrounded with quotes as it would try to find the executable named/bin/bash -c -l
and would fail. So you’re left with that or setting up a custom entrypoint script.If you’re only looking to do this once, then you can override the entrypoint with the
--entrypoint
flag when usingdocker run
.Everything that comes after the image name is passed to the new entrypoint as arguments.
Alternatively, if you expect you will be doing this again, I would instead recommend either:
Creating a new image altogether with
docker commit
:Writing a custom Dockerfile:
and then build it:
You will end up with a new image (
mynewimage
) that has the desired entrypoint.