Docker基础教程(常用命令篇)
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
Docker基础教程(常用命令篇)的更多相关文章
- Docker基础和常用命令
Docker基础和常用命令 一,Docker 简介 1.1,什么是 Docker Docker 使用 Google 公司推出的 Go 语言 进行开发实现,基于 Linux 内核的 cgroup,nam ...
- Docker基础教程(命令详解)
# docker --help Usage: docker [OPTIONS] COMMAND [arg...] docker daemon [ --help | ... ] docker [ -h ...
- Linux基础之常用命令篇
一.命令的基本格式 [root@localhost~] root为用户名 -表示当前所在位置 localhost主机名 ‘#’超级用户 '$" 普通用户 命令的基本格式: 命令 [选项] [ ...
- Docker基础教程(安装篇)
Linux安装: 1.yum -y install docker-io 2.service docker start 3.chkconfig docker on Window安装: Docker 引擎 ...
- GItHub Git 基础教程 常用命令 命令
最近复习了一下Git的使用,简单总结了一些.以供以后查阅和大家参考. 一,安装 首先是Linux下: 打开shell ,输入 sudo apt-get install git-core 之后回车输入密 ...
- Docker 入门指南——常用命令
前面已经介绍了 Docker 的安装方式,本文总结一下使用 Docker 的基本概念和常用命令. 基本概念 镜像 Image 镜像是一些打包好的已有的环境,可以被用来启动和创建容器 容器 Contai ...
- 【转帖】Systemd 入门教程:命令篇
Systemd 入门教程:命令篇 Copy From http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-commands.html 感觉 ...
- Docker系列之常用命令操作手册
目录 1.安装虚拟机 2.安装Docker 3.Docker镜像操作 4.Docker容器操作 Docker系列之常用命令操作手册 继上一篇博客Docker系列之原理简单介绍之后,本博客对常用的Doc ...
- Linux 命令详解(七)Systemd 入门教程:命令篇
Systemd 入门教程:命令篇http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-commands.html
- (转)Systemd 入门教程:命令篇
Systemd 入门教程:命令篇 原文:http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-commands.html Systemd 入门 ...
随机推荐
- Android中去掉标题栏
在Android中去掉标题栏有三种方法,它们也有各自的特点. 1.在代码里实现 this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏 记 ...
- unidbgrid单元格操作
unidbgrid单元格操作 //GRID里回车替换TABfunction cellkeydown(sender, td, cellIndex, record, tr, rowIndex, e, eO ...
- zeppelin中运行spark streaming kakfa & 实时可视化
notebook方式运行spark程序是一种比较agile的方式,一方面可以体验像spark-shell那样repl的便捷,同时可以借助notebook的作图能力实现快速数据可视化,非常方便快速验证和 ...
- NODE-WEBKIT教程(5)NATIVE UI API 之FRAMELESS WINDOW
node-webkit教程(5)Native UI API 之Frameless window 文/玄魂 原文链接:http://www.xuanhun521.com/Blog/2014/4/15/n ...
- ADO.NET系列之事务和调用存储过程
ADO.NET系列之Connection对象 ADO.NET系列之Command对象 ADO.NET系列之DataAdapter对象 ADO.NET系列之事务和调用存储过程 前几篇我们介绍了Conne ...
- XAML 调试工具 不见了?
XAML调试工具不见了怎么办? 1.调试---> 选项---> 选中 启用XAML的UI调试工具 2.调试---> 选项---> 禁用 使用托管兼容模式 欧了!
- Unity 环境区域网格化
在使用A星算法和物体布局的过程中,常常会使用的网格的概念,即建立在网格的基础上,会使得游戏的相关编程变得简单的多. 格子的代码: using System.Collections; using Sys ...
- nginx root&alias 文件路径配置
nginx 指定文件路径有两种方式 root 和 alias,root 与 alias 主要区别在于 nginx 如何解释 location 后面的 uri,这会使两者分别以不同的方式将请求映射到服务 ...
- C#6.0语言规范(六) 转换
转换能够被视为是一个特定类型的表达式.转换可能会导致给定类型的表达式被视为具有不同的类型,或者它可能导致没有类型的表达式获取类型.转换可以是隐式或显式的,这决定了是否需要显式转换.例如,从类型int到 ...
- js变量提升
JavaScript的函数定义有个特点,它会先扫描整个函数体的语句,把所有申明的变量“提升”到函数顶部: 'use strict'; function foo() { var x = 'Hello, ...