
VPS教程
docker images
Docker镜像默认本地存储到/var/lib/docker/image/目录下。
#搜索nginx镜像
docker search nginx
#下载nginx镜像
docker pull nginx
#删除MySQL5.7镜像
docker rmi 镜像ID
#强制删除MySQL5.7镜像
docker rmi -f 镜像ID
#导入镜像
docker load < 镜像包
docker load -i 镜像包
#其中-o表示指定文件名称
docker save -o CentOS7.tar 192.168.1.91/web/centos7:v1
#创建并启动CentOS7.7虚拟机,其中-i代表交互模式,-t代表tty终端,-d代表后台运行;
docker run -itd –name CentOS7.7 –privileged=true daocloud.io/centos:7 /usr/sbin/init
docker ps
docker ps -a
#停止alpine容器(虚拟机)
docker stop 容器ID
#启动alpine容器(虚拟机)
docker start 容器ID
#删除alpine容器(虚拟机)
docker rm 容器ID
#强制删除alpine容器(虚拟机)
docker rm -f 容器ID
#重启alpine容器
docker restart 容器ID
#进入alpine容器
docker exec -it 容器ID /bin/sh
docker exec -it 容器ID /bin/bash
#实时查看末尾10行日志
docker logs –tail=10 -f tomcat9
#实时查看最近一分钟的日志
docker logs -f tomcat9 –since=1m
#查看某时间段日志
docker logs -t –since=”2018-02-08T13:23:37″ –until “2018-02-09T12:23:37” CONTAINER_ID
#查看tomcat9容器的详细信息
docker inspect tomcat9
#查看tomcat9容器IP地址
docker inspect tomcat9 | grep “IPAddress” -w | awk -F ‘”‘ ‘NR==1{print $(NF-1)}’
#监控所有容器的状态
docker stats
#监控tomcat容器状态
docker stats tomcat9
#静态监控tomcat容器状态
docker stats –no-stream tomcat9
docker rmi -f $(docker images|grep none -w|awk ‘{print $3}’)
docker rm -f $(docker ps -a|grep Exited -w|awk ‘{print $1}’)