Set Container To Run A Bash Command On Start

Create Docker Container With Entrypoint And Default Command

Create a Docker container (docker container create) called application (--name application) built of the ubuntu:latest image. Upon starting the container launches bash (--entrypoint "/bin/bash") and runs -c "echo 'hello world'".

docker container create --name application --entrypoint "/bin/bash" ubuntu:latest -c "echo 'hello world'"
70a1a028a374e5c61007c01062c8be0f59a4406a89000ea0a59451553628a0bf

Create New Image

Create a new image (docker container commit) from the application container called new-application. Add author info (-a "Chris Albon") and a commit message (-m "Added analysis file").

docker container commit -a "Chris Albon" -m "Added entrypoint and command" application new-application
sha256:ce5f6bd0eb9f474ee8491d0e49e356260ef8daf591946539cf84201fd6253168

Run New Image

Run the docker container (docker container run) called new-application.

docker container run new-application
hello world