Docker常用命令
查看日志
- 查看日志(滚动所有):docker logs -f xxx
- 查看日志(后5行):docker logs –tail=5 xxx
- 查看日志(前10行):docker logs -f 130336220f1c |grep 1003303 |head -n 10
查看正在运行的容器
docker ps | grep wv
进入容器
- docker exec -it xxx bash
- cd /home/data2
查看进程
docker top 8ba
Docker 镜像
列出镜像列表
- docker images
- docker images | grep wv
Docker查询
root@acyou:/workspace# docker search nginx
下载到本地镜像
root@acyou:/workspace# docker pull nginx
删除镜像
root@acyou:/workspace# docker rmi nginx
Docker 容器互联
查看Docker中的网络
root@acyou:~# docker network ls
创建一个新的 Docker 网络。
root@acyou:~# docker network create -d bridge test-net
运行两个个容器并连接到新建的 test-net 网络进行测试:
- docker run -itd –name test1 –network test-net ubuntu /bin/bash
- docker run -itd –name test2 –network test-net ubuntu /bin/bash
1
2
3
4docker exec -it test1 /bin/bash
apt-get update
apt install iputils-ping
root@6c38917e25b6:/# ping test2