Docker的使用(1)
开篇
Docker 是一个开源的应用容器引擎,基于 Go 语言 并遵从Apache2.0协议开源。
Docker 可以让开发者打包他们的应用以及依赖包到一个轻量级、可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。
容器是完全使用沙箱机制,相互之间不会有任何接口(类似 iPhone 的 app),更重要的是容器性能开销极低。
Docker的优点
1、简化程序:
Docker 让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,便可以实现虚拟化。Docker改变了虚拟化的方式,使开发者可以直接将自己的成果放入Docker中进行管理。方便快捷已经是 Docker的最大优势,过去需要用数天乃至数周的 任务,在Docker容器的处理下,只需要数秒就能完成。
2、避免选择恐惧症:
如果你有选择恐惧症,还是资深患者。Docker 帮你 打包你的纠结!比如 Docker 镜像;Docker 镜像中包含了运行环境和配置,所以 Docker 可以简化部署多种应用实例工作。比如 Web 应用、后台应用、数据库应用、大数据应用比如 Hadoop 集群、消息队列等等都可以打包成一个镜像部署。
3、节省开支:
一方面,云计算时代到来,使开发者不必为了追求效果而配置高额的硬件,Docker 改变了高性能必然高价格的思维定势。Docker 与云的结合,让云空间得到更充分的利用。不仅解决了硬件管理的问题,也改变了虚拟化的方式。
Docker的安装
docker下载网址:https://www.docker.com/get-started
可以根据自己的系统下载对应的版本进行安装即可。
Docker使用
我们可以直接输入 docker 命令来查看到 Docker 客户端的所有命令选项:
lssdeMacBook-Pro:~ lss$ docker
Usage: docker [OPTIONS] COMMAND
A self-sufficient runtime for containers
Options:
--config string Location of client config files (default
"/Users/lss/.docker")
-D, --debug Enable debug mode
-H, --host list Daemon socket(s) to connect to
-l, --log-level string Set the logging level
("debug"|"info"|"warn"|"error"|"fatal")
(default "info")
--tls Use TLS; implied by --tlsverify
--tlscacert string Trust certs signed only by this CA (default
"/Users/lss/.docker/ca.pem")
--tlscert string Path to TLS certificate file (default
"/Users/lss/.docker/cert.pem")
--tlskey string Path to TLS key file (default
"/Users/lss/.docker/key.pem")
--tlsverify Use TLS and verify the remote
-v, --version Print version information and quit
Management Commands:
checkpoint Manage checkpoints
config Manage Docker configs
container Manage containers
image Manage images
network Manage networks
node Manage Swarm nodes
plugin Manage plugins
secret Manage Docker secrets
service Manage services
stack Manage Docker stacks
swarm Manage Swarm
system Manage Docker
trust Manage trust on Docker images
volume Manage volumes
Commands:
attach Attach local standard input, output, and error streams to a running container
build Build an image from a Dockerfile
commit Create a new image from a container's changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
deploy Deploy a new stack or update an existing stack
diff Inspect changes to files or directories on a container's filesystem
events Get real time events from the server
exec Run a command in a running container
export Export a container's filesystem as a tar archive
history Show the history of an image
images List images
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on Docker objects
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
login Log in to a Docker registry
logout Log out from a Docker registry
logs Fetch the logs of a container
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container
ps List containers
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rename Rename a container
restart Restart one or more containers
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save one or more images to a tar archive (streamed to STDOUT by default)
search Search the Docker Hub for images
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
wait Block until one or more containers stop, then print their exit codes
Run 'docker COMMAND --help' for more information on a command.
Docker常用命令:
docker image pull hello-world 下载一个镜像
docker images 查看已经安装的docker镜像
下一篇在接着更新吧!
Docker资源汇总
Docker官方英文资源
docker官网:http://www.docker.com
Docker windows入门:https://docs.docker.com/windows/
Docker Linux 入门:https://docs.docker.com/linux/
Docker mac 入门:https://docs.docker.com/mac/
Docker 用户指引:https://docs.docker.com/engine/userguide/
Docker 官方博客:http://blog.docker.com/
Docker Hub: https://hub.docker.com/
Docker开源: https://www.docker.com/open-source
Docker中文资源
Docker中文网站:http://www.docker.org.cn
Docker安装手册:http://www.docker.org.cn/book/install.html
一小时Docker教程 :https://blog.csphere.cn/archives/22
Docker 从入门到实践:http://dockerpool.com/static/books/docker_practice/index.html
Docker中文指南:http://www.widuu.com/chinese_docker/index.html
其它资源
https://segmentfault.com/t/docker
https://github.com/docker/docker
https://wiki.openstack.org/wiki/Docker
https://wiki.archlinux.org/index.php/Docker
总结
Dockerfile 文件
具体的详细内容下一篇在更吧,我瞌睡的不行了!