An image is related to a container just like a class is to an instance of a class, so an image can create multiple instances of a container that do not interfere with each other.
View all current mirrors
You can run the docker images or docker image ls command to view existing images on the host.
Only container instances are created
If you only want to create an instance based on an existing image, just run the docker create command.
Create and run a container instance
The easiest way is to use the Docker run command, using the -d parameter if you want it to run in the background, or the -i parameter if you want interactive input.
docker run
= docker create
+ docker start
Note: When the docker run command is used to create container instances, the pre-set or parameter passed commands will be executed. However, if there is no foreground application continuously executed inside the container (or manually exit the container), then the created container will be in exited state, which can be viewed through Docker PS A.
Rename the container instance
If you do not use the –name parameter when creating a container, then Docker will randomly generate a name. Sometimes you may want to rename the container instance by using the docker rename command.
The script is executed in the running container
After exiting the container shell (provided that the container is in the running state), you can use the docker-exec command to execute commands in the container shell.
other
Docker run vs. Docker Exec
Docker – Container – Cnblogs.com