I downloaded the ubuntu base image from the docker hub. Now I am trying to build a new image based on the ubuntu image. However, I want the default command for the ubuntu image to be "/bin/bash -c" instead of "/bin/sh" so as when I use RUN in my Dockerfile, it accesses bash instead of sh. Notice I am talking about the default command of the same image, not the image I am trying to build.
As the operator (the person running a container from the image), you can override that CMD just by specifying a new COMMAND. If the image also specifies an ENTRYPOINT then the CMD or COMMAND get appended as arguments to the ENTRYPOINT. So to do what you want you need only specify a cmd, and override using /bin/bash .
A base image is the image that is used to create all of your container images. Your base image can be an official Docker image, such as Centos, or you can modify an official Docker image to suit your needs, or you can create your own base image from scratch.
Docker CMD defines the default executable of a Docker image. You can run this image as the base of a container without adding command-line arguments. In that case, the container runs the process specified by the CMD command.
maybe this can help:
SHELL ["/bin/bash", "-c"]
Reference: https://github.com/moby/moby/issues/7281#issuecomment-389440503
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With