docker 使用教程(2)常用命令
1. 查看docker信息(version、info) # 查看docker版本 # 显示docker系统的信息 2. 对image的操作(search、pull、images、rmi、history) # 检索image # 下载image # 列出镜像列表; -a,--all=false Show all images; --no-trunc=false Don't truncate output; -q,--quiet=false Only show numeric IDs # 删除一个或者多个镜像; -f,--force=false Force; --no-prune=false Do not delete untagged parents # 显示一个镜像的历史; --no-trunc=false Don't truncate output; -q,--quiet=false Only show numeric IDs
? docker容器可以理解为在沙盒中运行的进程。这个沙盒包含了该进程运行所必须的资源,包括文件系统、系统类库、shell 环境等等。但这个沙盒默认是不会运行任何程序的。你需要在沙盒中运行一个进程来启动某一个容器。这个进程是该容器的唯一进程,所以当该进程结束的时候,容器也会完全的停止。 # 在容器中运行"echo"命令,输出"hello word" # 交互式进入容器中
Note: 在执行apt-get 命令的时候,要带上-y参数。如果不指定-y参数的话,apt-get命令会进入交互模式,需要用户输入命令来进行确认,但在docker环境中是无法响应这种交互的。apt-get 命令执行完毕之后,容器就会停止,但对容器的改动不会丢失。 ? 4. 查看容器(ps) ? # 列出当前所有正在运行的container
? 当你对某一个容器做了修改之后(通过在容器中运行某一个命令),可以把对容器的修改保存下来,这样下次可以从保存后的最新状态运行该容器。 # 保存对容器的修改; -a,--author="" Author; -m,--message="" Commit message ? 6. 对容器的操作(rm、stop、start、kill、logs、diff、top、cp、restart、attach) ? # 删除所有容器 # 删除单个容器; -f,--force=false; -l,--link=false Remove the specified link and not the underlying container; -v,--volumes=false Remove the volumes associated to the container # 停止、启动、杀死一个容器 # 从一个容器中取日志; -f,--follow=false Follow log output; -t,--timestamps=false Show timestamps # 列出一个容器里面被改变的文件或者目录,list列表会显示出三种事件,A 增加的,D 删除的,C 被改变的 # 显示一个运行的容器里面的进程信息 # 从容器里面拷贝文件/目录到本地一个路径 # 重启一个正在运行的容器; -t,--time=10 Number of seconds to try to stop for before killing the container,Default=10 # 附加到一个运行的容器上面; --no-stdin=false Do not attach stdin; --sig-proxy=true Proxify all received signal to the process ? 7. 保存和加载镜像(save、load) ? 当需要把一台机器上的镜像迁移到另一台机器的时候,需要保存镜像与加载镜像。 # 保存镜像到一个tar包; -o,--output="" Write to an file # 机器a
? # 登陆registry server; -e,--email="" Email; -p,--password="" Password; -u,--username="" Username
? # 发布docker镜像
? #build (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |