1. DockerDocker is a very powerful tool for packaging applications, enabling the operating system to be put into a package for non-discriminatory deployment and operation. So Docker is also considered a virtual machine built on the operating system.
2. Basic ConceptsImage: An image of a similar operating system, including a fully operational system, the operating system, the underlying components, and the application can be packaged in one image. Container (Container): A container is an execution instance of a docker image that can be started, closed, deleted, understood as a Linux system, and multiple container on the same machine are isolated from each other.
3. Easy to use#安装docker (centos6.5 above) Yum install-y epel-releaseyum update-y device-mapperyum erase-y dockeryum install-y docker-ioser Vice Docker status #从官方仓库中下载imagedocker pull Centosdocker pull ubuntu #查看本地可用的imagedocker images #启动一个centos的dokcer容器, Go directly to Bashdocker run-it CentOS bash #后台启动一个centos的dokcer容器docke r run-d-it CentOS #后台启动一个centos的dokcer容器, monitor 80 ports, map 8080 ports in the container Docke R run-p 80:8080-d-it CentOS #查看正在运行的docker容器docker PS #查看所有docker容器docker ps-a #在运行状态的容器里启动一个bash Docker exec-it $container _id bash #启动/off/restart container docker start/stop/restart $container _id #删除容器docker rm $c (into a running container) ontainer_id
4. Create A custom image, package your appmkdir test_imagecd test_image# Create Dockerfilevi Dockerfile
# Custom Image
#继承一个已有的镜像, this is based on Cetos.
From CentOS
Maintainer Luo <[email protected]>
#安装一些基础组件
RUN Yum install-y java-1.7.0-openjdk
#把应用程序放入镜像 (app1.tar.gz in a sibling directory beforehand
)
RUN mkdir/yazuo_apps/
ADD app1.tar.gz/yazuo_apps/
#打包镜像, the image is named App1 and the version is 1.0docker build-t app1:1.0. #启动镜像, and start App1, map the 8080 port of this machine to the 8080 port of the container Docker run-d-P 8080:8080-it/yazuo_apps/app1/start.sh # Export images (directly from a file to distribute mirrors to other machines) Docker Save-o App1-1.0.image app1:1.0
Docker notes (Basic concepts, quick run, custom images)