Nginx entry (II): mirroring and containers

0.docker commonly used commands

#镜像名            版本标签            镜像id             创建时间           镜像大小
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              fce289e99eb9        6 months ago        1.84kB
docker version/info #查看版本/信息
docker --help #查看说明文档
docker logs -f -t --tail 日志条数 容器ID #查看容器日志
docker inspect #获取容器/镜像的元数据

1. The basic operation of the mirror

1.1 mirroring operation

1.1.1 Pull

docker search [xxx] #查找名为xxx的镜像
docker pull [xxx]:版本号 # 拉取xxx镜像,不加版本号则默认拉取最新版本

1.1.2 View

docker images -a/-qa #列出本地全部镜像/全部镜像的ID

1.1.2 Delete

docker rmi -f [xxx] #删除名为xxx的镜像,加-f为强制删除(不论现在正在运行)
docker rmi $(docker images -q) #删除所有镜像

Note: To pull a mirror name wrong not to confirm, otherwise it will error (repository does not exist or may require 'docker login')

2.2.3 Export Mirror

#保存镜像到指定目录
#这里的原image名和版本号需要与要保存的镜像一致
docker save  镜像ID -o d:\dockerimages\新image名.tar 原image名:版本号

2.2.4 introduced mirror

#从指定目录加载镜像
docker load -i \dockerimages\新image名.tar

2. The basic operation of the container

2.1 New / run container

#-i为以交互模式启动容器
#-t为容器重新分配一个伪输入终端(两者合写为-it)
#--name为容器命名,不加则默认自动分配
docker run -it --name mycentos centos

#创建守护式容器
#直接在后台创建一个容器,但是如果容器里没有活动则会在创建后立刻自动停止
docker run -d centos

#8080为docker服务对外暴露的端口,8080指docker内的tomcat端口
docker run -it -p 8080:8080 tomcat

2.2 Operation container

2.2.1 View

docker ps #查看当前运行的容器
docker ps -l #列出最近创建的容器
docker ps -a #列出当前和曾经运行的容器
docker ps -n x #显示最近运行过的n个容器
#在以上基础上变为 -xq 可以只显示容器编号

#如果找不到命令,则可能为该镜像没有包含procps工具
apt-get update && apt-get install procps

2.2.2 enter

#在已运行的容器中,执行命令,操作对象是容器,如果你要进入已运行的容器,并且执行命令,用exec;
docker exec -it 容器名/容器ID /bin/bash
#同样操作的是已运行的容器,可以将本机标准输入(键盘输入)输到容器中,也可以将容器的输出显示在本机的屏幕上,如果你想查看容器运行过程中产生的标准输入输出,用attach;
docker attach 容器名/容器ID

2.2.3 Stop

docker stop 容器名/容器ID #停止单个
docker stop $(docker ps -a -q) #停止全部
docker kill 容器名/容器ID #强制停止

2.2.4 Exit

exit #容器停止并退出
ctrl+P+Q #容器不停止退出(非常重要!!!!!!!)

2.2.5 Delete

docker rm 容器名/容器ID #删除单个
docker rm $(docker ps -a -q) #删除全部

Note: rm to delete container, rmi to remove the mirror

2.5 The author vessel

docker commit -m="描述信息" -a="作者" 容器ID 要创建的新镜像名:版本号

2.6 to copy files from the host to the vessel

docker cp 容器名/容器ID:文件位置 /root

Guess you like

Origin www.cnblogs.com/Createsequence/p/11445655.html