Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between the docker commands: run, build, and create

Tags:

docker

I see there are three docker commands that seem to do very similar things:

  1. docker build
  2. docker create
  3. docker run

What are the differences between these commands?

like image 778
Jeff Widman Avatar asked May 29 '16 18:05

Jeff Widman


People also ask

What is the difference between docker run and docker create?

docker create command creates a writeable container from the image and prepares it for running. docker run command creates the container (same as docker create ) and starts it.

What is the difference between docker and Run command?

RUN is an image build step, the state of the container after a RUN command will be committed to the container image. A Dockerfile can have many RUN steps that layer on top of one another to build the image. CMD is the command the container executes by default when you launch the built image.

What is docker build command?

The docker build command builds Docker images from a Dockerfile and a “context”. A build's context is the set of files located in the specified PATH or URL . The build process can refer to any of the files in the context. For example, your build can use a COPY instruction to reference a file in the context.

What is the difference between docker commands up run and start?

The run command acts like docker run -ti in that it opens an interactive terminal to the container and returns an exit status matching the exit status of the process in the container. The docker compose start command is useful only to restart containers that were previously created, but were stopped.


1 Answers

  1. docker build builds a new image from the source code.
  2. docker create creates a writeable container from the image and prepares it for running.
  3. docker run creates the container (same as docker create) and runs it.
like image 176
NetworkMeister Avatar answered Oct 15 '22 17:10

NetworkMeister