common docker commands 2022-01-1

2022-01-16  本文已影响0人  9_SooHyun

docker run: 启动一个docker容器

docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

docker ps

查看正在运行的容器:

runoob@runoob:~#  docker ps
CONTAINER ID        IMAGE               COMMAND             ...        PORTS                 
d3d5e39ed9d3        training/webapp     "python app.py"     ...        0.0.0.0:32769->5000/tcp

这里多了端口信息。

PORTS
0.0.0.0:32769->5000/tcp

表示宿主机端口 32769 映射到Docker 5000 端口(默认 Python Flask 端口),或者说Docker 5000 端口绑定了宿主机32769端口

docker stop / docker kill

亲测stop会比kill耗时,kill会直接杀死运行中的container
So ideally we always stop a container with the docker stop command in order to get the running process inside of it a little bit of time to shut itself down, otherwise if it feels like the container has locked up and it's not responding to the docker stop command then we could issue docker kill instead.

上一篇 下一篇

猜你喜欢

热点阅读