Article Directory
Internal structure of container
Internal structure of tomcat container
You can see that the inside of the container is layered
How to enter the container and execute commands inside the container?
docker exec [-it] 容器id 命令
# exec 在对应的容器中执行命令
# -it 以交互式的方式执行命令
# 典型例子
docker exec -it 8d65e2aa6d1b /bin/bash
# 进入容器内部,并可以在容器内部执行linux命令
# 查看linux内核版本
cat /proc/version
# 查看操作系统版本
cat /etc/issue
The default storage directory for images and containers is/var/lib/docker
Container life cycle
In the figure below, the box represents the event , and the ellipse represents the state of the container .
For example, when you run the docker run command, you will experience two events, first the create event, creating the container, and then the start event, starting the container, and then the container enters the running state.
The docker create command only experienced the create event, created the container, and then the container was in the stopped state.
The difference between docker kill and docker stop:
They all experience the die event first and put the container in an unusable state.
But docker kill will trigger the kill event and will kill the process in the container; while docker stop will not kill the process in the container, and eventually the container will enter the stopped state. But if docker start is executed again, for the container that was previously killed by docker, the process in the container needs to be restarted; and the container that was previously stopped by docker does not need to restart the process in the container.
The difference between docker kill and docker stop is. When re-executing docker start to start the container, do you need to restart the process?
In general, just use docker stop.
docker pause triggers the paused event, which causes the container to become paused and enter the paused state. The suspended container can call docker unpause to re-enter the running state at any time
If the container oom occurs, the die event will be triggered, and then according to the restart policy configuration, it is determined whether to restart, if not, the container enters the stopped state.
docker rm will trigger the destroy event, making the container enter the deleted state
When you don’t need a container, you can directly
docker rm -f 3ab9e5a42c3a
in conclusion:
The container has 4 major states
- stopped
- running
- paused
- deleted
The stopped state is divided into two sub-states: created and exited
The running status will be displayed as up
The paused state will be displayed as paused
In the deleted state, the container is no longer visible