Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the default command of base docker images

Tags:

docker

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.

like image 627
Keeto Avatar asked Jun 19 '14 23:06

Keeto


People also ask

How do I change the docker image command?

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 .

What is the base of every docker image?

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.

What is docker default command?

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.


1 Answers

maybe this can help:

SHELL ["/bin/bash", "-c"]

Reference: https://github.com/moby/moby/issues/7281#issuecomment-389440503

like image 79
John Cymmer Avatar answered Oct 08 '22 01:10

John Cymmer