Home >Operation and Maintenance >Docker >What is the difference between run and start in docker
The difference between run and start in docker: the run command is only used when running the image operation for the first time, which is equivalent to performing a two-step operation, putting the image into the container and then starting the container; while the start command is used when Used when restarting an existing image. To use this command, you need to know the container's ID or name.
The operating environment of this tutorial: linux7.3 system, docker-1.13.1 version, Dell G3 computer.
docker run is equivalent to performing a two-step operation: putting the image into the container (docker create), and then starting the container to make it into a runtime container (docker start).
The function of docker start is to restart the existing image. That is to say, if we use this command, we must know the ID of the container or the name of the container in advance. We can use docker ps to find the information of the container.
Because the ID of the container is a random code, and the name of the container is a seemingly meaningless name, we can use the command
docker rename old_name new_name
to give this container name. In this way, when we start or stop the container again, we can use this name directly.
docker [stop] [start] new_name
To display all containers, including those that have not been started, you can use the command
docker ps -a
Recommended learning: "docker video tutorial"
The above is the detailed content of What is the difference between run and start in docker. For more information, please follow other related articles on the PHP Chinese website!