1、查看docker信息

# 查看docker版本
$docker version # 显示docker系统的信息
$docker info

2、启动容器

# 交互式
$docker run -it image_name /bin/bash # 后台式
$docker run -d image_name

3、查看容器

# 列出当前所有正在运行的container
$docker ps # 列出所有的container
$docker ps -a # 列出最近一次启动的container
$docker ps -l

4、保存修改

# 保存对容器的修改; -a, --author="" Author; -m, --message="" Commit message
$docker commit ID new_image_name

5、对镜像的操作

# 检索image
$docker search image_name # 下载image
$docker pull image_name # 列出镜像列表; -a, --all=false Show all images; --no-trunc=false Don't truncate output; -q, --quiet=false Only show numeric IDs
$docker images # 删除一个或者多个镜像; -f, --force=false Force; --no-prune=false Do not delete untagged parents
$docker rmi image_name # 显示一个镜像的历史; --no-trunc=false Don't truncate output; -q, --quiet=false Only show numeric IDs
$docker history image_name

6、对容器的操作

# 删除所有容器
$docker rm `docker ps -a -q` # 删除单个容器; -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
$docker rm Name/ID # 停止、启动、杀死一个容器
$docker stop Name/ID
$docker start Name/ID
$docker kill Name/ID # 从一个容器中取日志; -f, --follow=false Follow log output; -t, --timestamps=false Show timestamps
$docker logs Name/ID # 列出一个容器里面被改变的文件或者目录,list列表会显示出三种事件,A 增加的,D 删除的,C 被改变的
$docker diff Name/ID # 显示一个运行的容器里面的进程信息
$docker top Name/ID # 从容器里面拷贝文件/目录到本地一个路径
$docker cp Name:/container_path to_path
$docker cp ID:/container_path to_path # 重启一个正在运行的容器; -t, --time= Number of seconds to try to stop for before killing the container, Default=
$docker restart Name/ID # 附加到一个运行的容器上面; --no-stdin=false Do not attach stdin; --sig-proxy=true Proxify all received signal to the process
$docker attach ID

7、保存和加载镜像

# 保存镜像到一个tar包; -o, --output="" Write to an file
$docker save image_name -o file_path
# 加载一个tar包格式的镜像; -i, --input="" Read from a tar archive file
$docker load -i file_path # 机器a
$docker save image_name > /home/save.tar
# 使用scp将save.tar拷到机器b上,然后:
$docker load < /home/save.tar

8、发布镜像

# 发布docker镜像
$docker push new_image_name

9、进入容器

$docker exec -it ID /bin/bash 

10、退出容器

exit或Ctrl+D

最新文章

  1. Notepad++源码编译及其分析
  2. PHP去重算法的优化过程
  3. mysql日志类型
  4. 完成了server和client的框架设计
  5. mysql 分页存储过程 一次返回两个记录集(行的条数,以及行记录),DataReader的Read方法和NextResult方法
  6. 蟠桃记 AC 杭电
  7. BootStrap 模态框禁用空白处点击关闭,手动显示隐藏,垂直居中
  8. poj2392 Space Elevator(多重背包)
  9. Android记住密码自动登录的实现
  10. HttpHelper万能框架V1.6
  11. angularJS directive详解(自定义指令)
  12. 第9条:try-with-resources优于try-finally
  13. MySQL 支持的数据类型
  14. 大话设计模式之模板模式 C#
  15. LM &amp;&amp; NTLM &amp;&amp; ophcrack &amp;&amp; RainBow table
  16. java框架篇---hibernate之CRUD操作
  17. 高性能Java RPC框架Dubbo与zookeeper的使用
  18. Linux命令_用户身份切换
  19. Asp.net Vnext 实现IView
  20. Template Method Design Pattern in Java

热门文章

  1. 转载:readLine()与read()
  2. express package.json解析
  3. map 小模板~~~ 写的不好 继续添加
  4. 彻底卸载Oracle database 12c教程
  5. 【vue】项目编译报错‘npm ERR! **@**dev: `webpack-dev-server --inline --progress --config ’’
  6. ovs flow 命令集
  7. MQ的demo
  8. 201621123018《java程序设计》第12周作业总结
  9. IDFA
  10. Maximum repetition substring(POJ - 3693)(sa(后缀数组)+st表)