ps: a vessel or a set of applications operate independently, and the operation-environment
Start container
- Two ways to start a: based images and start a new container; two: Restart the container state to be terminated
- Create and start
-
- The main command
docker run
- The main command
-
- Start a bash terminal
ps: -t option lets docker allocate a pseudo-terminal and bind to the standard input container, -i so that the container remains open standard input
- Start a bash terminal
- When the container is created using the docker run, standard practice in the background docker comprising:
- Check whether there are specific local mirror, does not exist in the public warehouse download
- Use a mirror to create and launch container
- Assign a file system, and a mirror mounted on the outside layer of the read-only and writable layer
- Host bridge configuration from the host bridge interface to a virtual interface to the container
- Configuring an ip address from the address pool container
- Execution of the application specified by the user
- After completion of the implementation of the container is terminated
Start container has been terminated
- Available docker container start command has terminated directly to a container up and running
- The core container is performed by the application, the required resources are necessary to run the application
Background process
-
By -d parameter lets docker run in the background, not the execution result output on the host. The output can be used to view docker logs, start using the -d parameter returns a unique ID
-
docker container ls to view container information
Termination container
-
docker container stop
Terminate the operation of the vessel
-
docker container ls -a
View the final state of the container
Into the container
-
Can be used docker attach or docker exec (recommended) command into the container
-
attach command
daemon process started
listing all containers
entering the vessel
PS: If this current from the container exit, it will cause the container to stop -
exec command
docker exec -it {container id} bash
ps: When the exit from the container, the container does not cause to stop
Export and import container
- Export container , the container can be to a local snapshot
docker export {container ID} > export_name.tar
- Introducing snapshot of the container , the container can be introduced from the local snapshot to the mirror
cat {快照文件} docker import - test/{镜像名}:{tag}
may be introduced by its URL,docker import {URL}
- Docker load may be used to import image files stored in the local image library may be used to import a docker import container to the local snapshot image library. The difference is that the container will discard all snapshot files and metadata history information image file is stored intact record a larger volume. Introducing labels can reassign metadata information snapshot files from the container
Delete container
- Use
docker container rm {容器}
delete one stop state of the container - For delete container running, you can add -f parameter
- Clean up all the container is terminated state:
docker container prune