do
引入
Docker是什么?
Docker 最初是 dotCloud 公司创始人 Solomon Hykes 在法国期间发起的一个公司内部项目,于 2013 年 3 月以 Apache 2.0 授权协议开源,主要项目代码在 GitHub 上进行维护。Docker 使用 Google 公司推出的 Go 语言 进行开发实现。docker是linux容器的一种封装,提供简单易用的容器使用接口。它是最流行的Linux容器解决方案。docker的接口相当简单,用户可以方便的创建、销毁容器。docker将应用程序与程序的依赖,打包在一个文件里面。运行这个文件就会生成一个虚拟容器。程序运行在虚拟容器里,如同在真实物理机上运行一样,有了docker,就不用担心环境问题了。
应用场景
- web应用的自动化打包和发布
- 自动化测试和持续集成、发布
- 在服务型环境中部署和调整数据库或其他应用
区别
1,物理机
二,虚拟机
三,docker容器
Docker的三大概念及优势
- 镜像 image
- 容器 container
- 仓库 repository
/
docker daemon [ </span>--help |<span style="color: #000000;"> ... ]
docker [ </span>--help | -v | --<span style="color: #000000;">version ]
A
self
-sufficient runtime <span style="color: #0000ff;">for<span style="color: #000000;"> containers.
Options:
--config=~/.docker Location of client config files <span style="color: #008000;">#<span style="color: #008000;">客户端配置文件的位置
-D,--debug=false Enable debug mode <span style="color: #008000;">#<span style="color: #008000;">启用Debug调试模式
-H,--host=[] Daemon socket(s) to connect to <span style="color: #008000;">#<span style="color: #008000;">守护进程的套接字(Socket)连接
-h,--help=false Print usage <span style="color: #008000;">#<span style="color: #008000;">打印使用
-l,--log-level=info Set the logging level <span style="color: #008000;">#<span style="color: #008000;">设置日志级别
--tls=false Use TLS; implied by--tlsverify <span style="color: #008000;">#
--tlscacert=~/.docker/ca.pem Trust certs signed only by this CA <span style="color: #008000;">#<span style="color: #008000;">信任证书签名CA
--tlscert=~/.docker/cert.pem Path to TLS certificate file <span style="color: #008000;">#<span style="color: #008000;">TLS证书文件路径
--tlskey=~/.docker/key.pem Path to TLS key file <span style="color: #008000;">#<span style="color: #008000;">TLS密钥文件路径
--tlsverify=false Use TLS <span style="color: #0000ff;">and verify the remote <span style="color: #008000;">#<span style="color: #008000;">使用TLS验证远程
-v,--version=false Print version information <span style="color: #0000ff;">and quit <span style="color: #008000;">#<span style="color: #008000;">打印版本信息并退出
<span style="color: #000000;">
Commands:
attach Attach to a running container </span><span style="color: #008000;">#</span><span style="color: #008000;">当前shell下attach连接指定运行镜像</span>
<span style="color: #000000;">
build Build an image <span style="color: #0000ff;">from a Dockerfile <span style="color: #008000;">#<span style="color: #008000;">通过Dockerfile定制镜像
<span style="color: #000000;">
commit Create a new image <span style="color: #0000ff;">from a container<span style="color: #800000;">'<span style="color: #800000;">s changes #提交当前容器为新的镜像
<span style="color: #000000;">
cp Copy files/folders <span style="color: #0000ff;">from a container to a HOSTDIR <span style="color: #0000ff;">or to STDOUT <span style="color: #008000;">#<span style="color: #008000;">从容器中拷贝指定文件或者目录到宿主机中
<span style="color: #000000;">
create Create a new container <span style="color: #008000;">#<span style="color: #008000;">创建一个新的容器,同run 但不启动容器
<span style="color: #000000;">
diff Inspect changes on a container<span style="color: #800000;">'<span style="color: #800000;">s filesystem #查看docker容器变化
<span style="color: #000000;">
events Get real time events <span style="color: #0000ff;">from the server<span style="color: #008000;">#<span style="color: #008000;">从docker服务获取容器实时事件
<span style="color: #0000ff;">exec</span> Run a command <span style="color: #0000ff;">in</span> a running container<span style="color: #008000;">#</span><span style="color: #008000;">在已存在的容器上运行命令</span>
<span style="color: #000000;">
export Export a container<span style="color: #800000;">'<span style="color: #800000;">s filesystem as a tar archive #导出容器的内容流作为一个tar归档文件(对应import)
<span style="color: #000000;">
history Show the history of an image <span style="color: #008000;">#<span style="color: #008000;">展示一个镜像形成历史
<span style="color: #000000;">
images List images <span style="color: #008000;">#<span style="color: #008000;">列出系统当前镜像
<span style="color: #0000ff;">import</span> Import the contents <span style="color: #0000ff;">from</span> a tarball to create a filesystem image <span style="color: #008000;">#</span><span style="color: #008000;">从tar包中的内容创建一个新的文件系统映像(对应export)</span>
<span style="color: #000000;">
info Display system-wide information <span style="color: #008000;">#<span style="color: #008000;">显示系统相关信息
<span style="color: #000000;">
inspect Return low-level information on a container <span style="color: #0000ff;">or image <span style="color: #008000;">#<span style="color: #008000;">查看容器详细信息
<span style="color: #000000;">
kill Kill a running container <span style="color: #008000;">#<span style="color: #008000;">kill指定docker容器
<span style="color: #000000;">
load Load an image <span style="color: #0000ff;">from a tar archive <span style="color: #0000ff;">or STDIN <span style="color: #008000;">#<span style="color: #008000;">从一个tar包中加载一个镜像(对应save)
<span style="color: #000000;">
login Register <span style="color: #0000ff;">or log <span style="color: #0000ff;">in to a Docker registry<span style="color: #008000;">#<span style="color: #008000;">注册或者登陆一个docker源服务器
<span style="color: #000000;">
logout Log out <span style="color: #0000ff;">from a Docker registry <span style="color: #008000;">#<span style="color: #008000;">从当前Docker registry退出
<span style="color: #000000;">
logs Fetch the logs of a container <span style="color: #008000;">#<span style="color: #008000;">输出当前容器日志信息
<span style="color: #000000;">
pause Pause all processes within a container<span style="color: #008000;">#<span style="color: #008000;">暂停容器
<span style="color: #000000;">
port List port mappings <span style="color: #0000ff;">or a specific mapping <span style="color: #0000ff;">for the CONTAINER <span style="color: #008000;">#<span style="color: #008000;">查看映射端口对应的容器内部源端口
<span style="color: #000000;">
ps List containers <span style="color: #008000;">#<span style="color: #008000;">列出容器列表
<span style="color: #000000;">
pull Pull an image <span style="color: #0000ff;">or a repository <span style="color: #0000ff;">from a registry <span style="color: #008000;">#<span style="color: #008000;">从docker镜像源服务器拉取指定镜像或者库镜像
<span style="color: #000000;">
push Push an image <span style="color: #0000ff;">or a repository to a registry <span style="color: #008000;">#<span style="color: #008000;">推送指定镜像或者库镜像至docker源服务器
<span style="color: #000000;">
rename Rename a container <span style="color: #008000;">#<span style="color: #008000;">重命名容器
<span style="color: #000000;">
restart Restart a running container <span style="color: #008000;">#<span style="color: #008000;">重启运行的容器
<span style="color: #000000;">
rm Remove one <span style="color: #0000ff;">or more containers <span style="color: #008000;">#<span style="color: #008000;">移除一个或者多个容器
<span style="color: #000000;">
rmi Remove one <span style="color: #0000ff;">or more images <span style="color: #008000;">#<span style="color: #008000;">移除一个或多个镜像(无容器使用该镜像才可以删除,否则需要删除相关容器才可以继续或者-f强制删除)
<span style="color: #000000;">
run Run a command <span style="color: #0000ff;">in a new container <span style="color: #008000;">#<span style="color: #008000;">创建一个新的容器并运行一个命令
<span style="color: #000000;">
save Save an image(s) to a tar archive<span style="color: #008000;">#<span style="color: #008000;">保存一个镜像为一个tar包(对应load)
<span style="color: #000000;">
search Search the Docker Hub <span style="color: #0000ff;">for images <span style="color: #008000;">#<span style="color: #008000;">在docker
<span style="color: #000000;">hub中搜索镜像
start Start one </span><span style="color: #0000ff;">or</span> more stopped containers<span style="color: #008000;">#</span><span style="color: #008000;">启动容器</span>
<span style="color: #000000;">
stats Display a live stream of container(s) resource usage statistics <span style="color: #008000;">#<span style="color: #008000;">统计容器使用资源
<span style="color: #000000;">
stop Stop a running container <span style="color: #008000;">#<span style="color: #008000;">停止容器
<span style="color: #000000;">
tag Tag an image into a repository <span style="color: #008000;">#<span style="color: #008000;">给源中镜像打标签
<span style="color: #000000;">
top Display the running processes of a container <span style="color: #008000;">#<span style="color: #008000;">查看容器中运行的进程信息
<span style="color: #000000;">
unpause Unpause all processes within a container <span style="color: #008000;">#<span style="color: #008000;">取消暂停容器
<span style="color: #000000;">
version Show the Docker version information<span style="color: #008000;">#<span style="color: #008000;">查看容器版本号
<span style="color: #000000;">
wait Block until a container stops,then <span style="color: #0000ff;">print its exit code <span style="color: #008000;">#<span style="color: #008000;">截取容器停止时的退出状态值
<span style="color: #000000;">
Run <span style="color: #800000;">'<span style="color: #800000;">docker COMMAND --help<span style="color: #800000;">' <span style="color: #0000ff;">for more information on a command. <span style="color: #008000;">#<span style="color: #008000;">运行docker命令在帮助可以获取更多信息