docker学习笔记(命令)

1,获取Centos镜像

[xml]docker pull centos:latest[/xml]

2,查看镜像运行情况

[xml]docker images centos[/xml]

3,在容器下运行 shell bash
[xml]docker run -i -t centos /bin/bash[/xml]

4,停止容器
[xml]docker stop <CONTAINER ID>[/xml]

5,查看容器日志
[xml]docker logs -f <CONTAINER ID>[/xml]

6,删除所有容器
[xml]docker rm $(docker ps -a -q)[/xml]

7,删除镜像
[xml]docker rmi <image id/name>[/xml]

8,进入容器

[xml]sudo docker exec -it <CONTAINER ID> /bin/bash [/xml]

9,查看Docker的底层信息

[xml]docker inspect <CONTAINER ID>[/xml]

10,启动/重启容器

[xml]docker start/restart <CONTAINER ID>[/xml]

11,连接进入docker

[xml]docker exec -it <CONTAINER ID> /bin/bash[/xml]

若出错:[sql]oci runtime error: exec failed: container_linux.go:265: starting container process caused “exec: \”/bin/bash\”: stat /bin/bash: no such file or directory”[/sql]

则执行:

[xml]docker exec -it <CONTAINER ID> /bin/sh[/xml]

Back to Top