The difference between docker run and start

The difference between docker run and start

The difference between run and start in docker

Docker run specifies a mirror image.

And docker start specifies a container

Docker run uses the image to generate a container and start the container, while Docker start starts a previously generated container.

try

Docker start starts a container that has already been created.

For example, my docker has a mirror of the springboot project

Then I use the docker run command to start it. Using docker ps, I can see that a springboot container has been started, and then we stop it (docker stop)

Then use docker start to start it, and then use docker ps to see that the previously stopped one has started.

[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
springbootdocker latest 5fe8370f7f83 25 hours ago 677 MB
daocloud.io/rabbitmq 3-management 1d0a5c8a8d4e 4 weeks ago 177 MB
daocloud.io/library/tomcat latest 89481b5d9082 7 weeks ago 506 MB
daocloud.io/library/mysql 5.5 d404d78aa797 3 months ago 205 MB
daocloud.io/library/java latest d23bdf5b1b1b 2 years ago 643 MB
docker.io/java 8 d23bdf5b1b1b 2 years ago 643 MB
[root@localhost ~]# docker run --name springboot -p 8080:8080 -d 5f
dd100a4c60a7a6606244873bc61a8a6f419361ab78fcd038d4baef3f38f05157
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
dd100a4c60a7 5f "java -Djava.secur..." 19 seconds ago Up 18 seconds 0.0.0.0:8080->8080/tcp springboot
[root@localhost ~]# docker stop dd
dd
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
dd100a4c60a7 5f "java -Djava.secur..." 39 seconds ago Exited (143) 3 seconds ago springboot
f3b181616dac 1d0a5c8a8d4e "docker-entrypoint..." 3 weeks ago Exited (255) 2 weeks ago 4369/tcp, 5671-5672/tcp, 0.0.0.0:5762->5762/tcp, 15671/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp myrabbit0
ea0a9cb0fe2f 89481b5d9082 "catalina.sh run" 4 weeks ago Exited (129) 4 weeks ago clever_leakey
[root@localhost ~]# docker start dd
dd
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
dd100a4c60a7 5f "java -Djava.secur..." About a minute ago Up 2 seconds 0.0.0.0:8080->8080/tcp springboot
[root@localhost ~]#

Supplement: Docker container start | restart | stop

Recently, when maintaining the Fabric network, a server power outage occurred. Except for the containers of Kafka and Zookeeper, all other containers were in the Exited state.

Ok, I need to restart the container

1. docker start

Start one or more stopped containers

docker start [OPTIONS] CONTAINER [CONTAINER...]
#You can start the container according to the container's Name or ID $ docker start ID/NAME

Options:
# -a parameter connects to the container and prints output or errors -a, --attach Attach STDOUT/STDERR and forward signals 
# I don't understand the parameters...
   --detach-keys string Override the key sequence for detaching a container
# -i parameter starts the container and enters interactive mode -i, --interactive Attach container's STDIN

2. docker restart

Restart the container, regardless of whether it was previously started or stopped

docker restart [OPTIONS] CONTAINER [CONTAINER...]
#You can restart the container according to the container's Name or ID $ docker restart ID/NAME

Options:
# -t parameter wait time before stopping the container (default 10 seconds)
 -t, --time int Seconds to wait for stop before killing the container (default 10)

3. docker stop

Stop a running container

docker stop [OPTIONS] CONTAINER [CONTAINER...]
#You can stop the container according to the container's Name or ID $ docker restart ID/NAME

Options:
# -t parameter wait time before stopping the container (default 10 seconds)
 -t, --time int Seconds to wait for stop before killing it (default 10)

With these commands, it is convenient to restart the stopped container.

Another point to note is that the chaincode container in the Fabric network does not need to be restarted using the above command. After the started peer node uses the query command to query, the chaincode container will be automatically started.

You may also be interested in:
  • Detailed explanation of the working principle and usage of the Docker image submission command commit
  • How to view the docker run startup parameter command (recommended)
  • Detailed explanation of the basic commands of Docker run process and image

<<:  Flex layout realizes left text overflow and omits right text adaptation

>>:  HTML text escape tips

Recommend

A simple example of creating a thin line table in html

Regarding how to create this thin-line table, a s...

JS realizes the scrolling effect of announcement online

This article shares the specific code of JS to ac...

Docker deploys net5 program to achieve cross-platform functions

Deployment environment: docker container, liunx s...

Font Treasure House 50 exquisite free English font resources Part 1

Designers have their own font library, which allo...

Three ways to achieve text flashing effect in CSS3 Example code

1. Change the transparency to achieve the gradual...

JavaScript data transmission between different pages (URL parameter acquisition)

On web pages, we often encounter this situation: ...

How to set up vscode remote connection to server docker container

Table of contents Pull the image Run the image (g...

Specific use of nginx keepalive

The default request header of the http1.1 protoco...

How to install Zookeeper service on Linux system

1. Create the /usr/local/services/zookeeper folde...

Detailed explanation of nginx forward proxy and reverse proxy

Table of contents Forward Proxy nginx reverse pro...

Implementation of docker redis5.0 cluster cluster construction

System environment: Ubuntu 16.04LTS This article ...

Native js to realize bouncing ball

On a whim, I wrote a case study of a small ball b...

Setting up shared folders in Ubuntu virtual machine of VMWare14.0.0

This is my first blog post. Due to time constrain...

Explanation of the precautions for Mysql master-slave replication

1. Error error connecting to master 'x@xxxx:x...