- Take me to Video Tutorial
In this section, we will take a look at commands and arguments in docker
-
To run a docker container
$ docker run ubuntu
-
To list running containers
$ docker ps
-
To list all containers including that are stopped
$ docker ps -a
-
Containers are meant to run a specific task or process such as to host an instance of a webserver or application server or a database server etc.
-
One Option is to append a command to the docker run command and that way it overrides the default command specified within the image.
$ docker run ubuntu sleep 5
-
This way when the container starts it runs the sleep program, waits for 5 seconds and then exists. How do you make that change permenent?
-
There are different ways of specifying the command either the command simply as is in a shell form or in a JSON array format.
-
Now, build the docker image
$ docker build -t ubuntu-sleeper .
-
Run docker container
$ docker run ubuntu-sleeper
- The entrypoint instruction is like the command instruction as in you can specify the program that will be run when the container starts and whatever you specify on the command line.