你未必出类拔萃,但一定与众不同
Docker
1.发布项目的时候,将项目和环境一起发布!开发打包部署上线,一套流程做完
2.多个应用(端口交叉)
隔离:打包装箱,每个箱子都是互相隔离的
java —apk—发布 应用商店 ----张三使用apk 安装即可用
java-----jar(环境)—打包项目带上环境(镜像) ----docker仓库 商店 下载我们发布的镜像 ----直接运行即可。
3.Docker是基于go语言开发的 开源项目
https://www.docker.com
https://docs.docker.com
Docker和虚拟机技术的不同
传统虚拟机 虚拟出一条硬件,运行一个完整的操作系统,然后在这个系统上安装和运行软件
容器内的应用直接运行在宿主机的内部,容器是没有自己的内科的,也没有虚拟我们的硬件,所以就轻便
每个容器都是互相隔离的 每个容器都有一个属于自己的文件系统 互不影响
应用更快速的交付和部署
传统 一堆帮助文档 安装程序
Docker 打包镜像想发布测试 一键运行
项目打包为一个镜像 扩展服务器A 扩展服务器B
在容器化以后 我们的开发 测试环境都是高度一致的
Docker是内核级别的虚拟化 可以在一个物理机上运行很多的容器实例
Docker安装
Docker的基本组成
镜像:
docker镜像 就好比是一个模板,可以通过模板来创建容器服务,tomcat镜像—》run—》tomcat容器
通过镜像可以创建多个容器 (最终服务器运行或者项目运行就是在容器中的)
容器
docker利用容器技术 独立运行一个或者一租应用 通过镜像来创建
启动 停止 删除 基本命令
目前就如同一个简易的 linux系统
仓库
仓库就是存放镜像的地方
仓库分为公有仓库和私有仓库
Docker Hub默认是国外的
阿里云 都有容器服务 配置容器加速
开始安装
1.卸载旧版本
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
2.安装一些工具
yum install -y yum-utils
3.设置镜像的仓库
yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
更新yum软件包索引
yum makecache fast
4.安装docker相关的资源 docker-ce 社区版 ee企业版
yum install docker-ce docker-ce-cli containerd.io
5.启动docker
systemctl start docker
6.查看版本
docker version
7.测试
docker run hello-world
[root@VM-0-6-centos ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:308866a43596e83578c7dfa15e27a73011bdd402185a84c5cd7f32a88b501a24
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
You have new mail in /var/spool/mail/root
[root@VM-0-6-centos ~]#
8.查看一下下载的镜像
docker images
[root@VM-0-6-centos ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest d1165f221234 5 weeks ago 13.3kB
卸载docker
1.卸载依赖
yum remove docker-ce docker-ce-cli containerd.io
2.删除资源
rm -rf /var/lib/docker
rm -rf /var/lib/containerd