1. Start the container
There are two ways to start a container, one is to create a new container based on the mirror and start, and the other is to restart the container in the terminating state (stopped).
New:
1.docker run centos:6/bin/echo ' Hello World ' #输出一个 "Hello World", then terminates the container
2.docker run-t-I centos:6/bin/bash #启动一个bash终端, allowing users to interact
-t
Option lets Docker assign a pseudo terminal (Pseudo-tty) and bind to the container's standard input, -i
keeping the container's standard input open.
When used docker run
to create a container, the standard operations that Docker runs in the background include:
- Checks if there is a specified image locally and does not exist to download from the public repository
- Create and start a container with mirroring
- Assign a file system and mount a layer of read-write layers outside the mirrored layer
- Bridging a virtual interface into a container from the bridge interface configured by the host host
- Configure an IP address from the address pool to the container
- Executing user-specified applications
- Container is terminated when execution is complete
Start a container that has been terminated
The command can be used to docker start
start a terminated container directly.
Docker start container name Docker stop container name
Docker Learning Notes (ii)