Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between docker run and docker container run

Tags:

docker

Can anyone help me in the understanding difference between docker run & docker container run?

when i do docker run --help & docker container run --help from docker cmd line. I see the following

Run a command in a new container.

Is there any difference in how they run the container internally or both are same doing same work?

As per https://forums.docker.com/t/docker-run-and-docker-container-run/30526. docker run is still the old one, which will be deprecated soon but same is not confirmed.

like image 456
adithya Avatar asked Jul 09 '18 14:07

adithya


People also ask

What is the difference between docker run?

The key difference between docker run versus docker-compose is that docker run is entirely command line based, while docker-compose reads configuration data from a YAML file. The second major difference is that docker run can only start one container at a time, while docker-compose will configure and run multiple.

What is the difference between docker run and docker start?

Docker start command will start any stopped container. If you used docker create command to create a container, you can start it with this command. Docker run command is a combination of create and start as it creates a new container and starts it immediately.

What is meant by docker run?

A container is a process which runs on a host. The host may be local or remote. When an operator executes docker run , the container process that runs is isolated in that it has its own file system, its own networking, and its own isolated process tree separate from the host.

What is the difference between docker run and Docker exec?

Docker Run vs Docker Exec! This is a fairly common question – but has a simple answer! In short, docker run is the command you use to create a new container from an image, whilst docker exec lets you run commands on an already running container! Easy!


3 Answers

They are exactly the same.

Prior to docker 1.13 the docker run command was only available. The CLI commands were then refactored to have the form docker COMMAND SUBCOMMAND, wherein this case the COMMAND is container and the SUBCOMMAND is run. This was done to have a more intuitive grouping of commands since the number of commands at the time has grown substantially.

You can read more under CLI restructured.

like image 180
yamenk Avatar answered Oct 23 '22 19:10

yamenk


docker run no, we aren't even hiding it, it's staying as a permanent alias.

The rest, not any time soon. Maybe in a year or two if we're good about converting all > the docs to the new form, and communicating the new canonical way of doing things.

So, they are exactly same, just format changed, see discusstion about this PR: https://github.com/moby/moby/pull/26025

like image 32
atline Avatar answered Oct 23 '22 20:10

atline


Maybe a bit late, but wanted to share a wider & cleaner image from The docker Handbook about the question:

Previously [...] the generic syntax for this command is as follows:

docker run <image name>

Although this is a perfectly valid command, there is a better way of dispatching commands to the docker daemon.

Prior to version 1.13, Docker had only the previously mentioned command syntax. Later on, the command-line was restructured to have the following syntax:

docker <object> <command> <options>

In this syntax:

  • <object> indicates the type of Docker object you'll be manipulating. This can be a container, image, network or volume object.
  • <command> indicates the task to be carried out by the daemon, that is the run command.
  • <options> can be any valid parameter that can override the default behavior of the command, like the --publish option for port mapping.

Thus,

docker container run :

  1. container is the object
  2. run is the command to be executed by Docker Daemon.
like image 3
SeleM Avatar answered Oct 23 '22 20:10

SeleM