3.17. 容器
它们是部分常用的 Docker 和 Podman 命令。
操作 | Docker RHEL7 | podman RHEL8 |
---|---|---|
显示所有正在运行的容器 | # Docker ps | # podman ps |
显示所有容器(运行、停止等) | # docker ps -a | # podman ps -a |
显示所有容器(运行、停止等),而不截断输出 | # docker ps -a --no-trunc | # podman ps -a --no-trunc |
显示所有容器(运行、停止等)json 输出 | # docker ps --format '{{ json .}}' | jq -C '.' s|# podman ps -a --format json | jq -C '.' |
显示给定容器的容器进程树 | # Docker top <container ID> | # podman pod top <container ID> |
显示实时容器资源使用率(CPU、内存、I/O、Net) - TOP | # Docker stats | # podman stats |
显示给定容器的实时资源利用率(CPU、内存、I/O、Net) - TOP | # Docker stats <container ID> | # podman stats <container ID> |
登录到给定的正在运行的容器 | # docker exec -it <container ID> /bin/bash | # podman exec -it <container ID> /bin/bash |
以 root 用户身份登录给定正在运行的容器 | # docker exec -u root -it <container ID> /bin/bash | # podman exec -u root -it <container ID> /bin/bash |
显示给定容器中的端口映射 | # Docker 端口 <container ID> | # podman port <container ID> |
显示名称、ID 和标签的所有本地存储的镜像 | # Docker image ls # docker images" | # podman image ls # podman images" |
显示给定镜像的历史记录 | # Docker history <image id> | # podman history <image id> |
显示给定容器的低级别配置 | # Docker inspect <container ID> | # podman inspect <container ID> |
显示给定容器的所有卷 | # docker inspect -f "{{ .Mounts }}" <container ID> | # podman inspect -f "{{ .Mounts }}" <container ID> |
重启具有相同模式的所有容器 | # docker ps -q --filter "name=swift" | xargs -n1 docker restart | # podman ps -q --filter "name=swift" | xargs -n1 docker restart |
有关 docker 或 podman 的更多信息,请参阅以下文档: