一、docker简介
1. docker诞生
docker 是 dotcloud 公司开源的一款产品,dotcloud 是2010年新成立的一家公司,主要基于 PAAS(Platfrom as a Service)平台为开发者提供服务。2013年10月dotcloud 公司改名为docker 股份有限公司。
2. docker 相关解释
Linux Container 是一种内核虚拟化技术,可以提供轻量级的虚拟化,以便隔离进程和资源。
docker 是 PAAS 提供商 dotcloud 开源的一个基于 LXC 的高级容器引擎,源代码托管在GitHub上,基于go 语言并遵从 Apache2.0 协议开源。即docker是基于go语言并遵从apache2.0协议的一个基于LXC 的高级容器引擎。
docker 设想是交付运行环境如同海运,OS 如同一个货轮,每一个在OS 基础上的软件如同一个集装箱,用户可以通过标准化手段自由组装运行环境,同时集装箱的内容可以由用户自定义,也可以由专业人员制造。
3. docker 与传统虚拟化对比
4. docker 的构成
docker 仓库:https://hub.docker.com/
docker 自身组件
docker client:docker 客户端
docker server:docker daemon 的主要组成部分,接受用户通过docker client 发出的请求,并按照相应的路由规则实现路由分发
docker 镜像:docker 镜像运行之后变成容器(docker run)
二、docker 安装
1. docker 的安装方式
1.1 shell 脚本安装
# yum update # curl -sSL https://get.docker.com/ |sh # systemctl start docker # systemctl enable docker # docker run hello-world Unable to find image ‘hello-world:latest‘ locally latest: Pulling from library/hello-world 1b930d010525: Pull complete Digest: sha256:d1668a9a1f5b42ed3f46b70b9cb7c88fd8bdc8a2d73509bb0041cf436018f 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 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/
1.2 yum 安装
# yum update # cd /etc/yum.repo.d/ # vim docker.repo [dockerrepo] name=Docker Repository baseurl=https://yum.dockerproject.org/repo/main/centos/7 enabled=1 gpgcheck=1 gpgkey=https://yum.dockerproject.org/gpg # yum -y install docker # systemctl start docker # systemctl enable docker # docker run hello-world
1.3 rpm 包安装
下载地址:https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
2. docker 镜像加速配置
# cp /lib/systemd/system/docker.service /etc/systemd/system/ # cd /etc/systemd/system/ # chmod a+x docker.service # vim docker.service ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd .sock --registry-mirror=https://ehkb3m8v.mirror.aliyuncs.com # systemctl daemon-reload # systemctl restart docker
https://ehkb3m8v.mirror.aliyuncs.com 获取方法
a. 进入阿里云镜像加速界面
https://cr.console.aliyun.com/#/accelerator
三、docker 容器管理
1. docker 基础概念
docker 三个重要概念:仓库(Repository)、镜像(image)、容器(Container)
docker -run --name MyWorkPress --link db:mysql -p 81:80 -d wordpress
docker 指令的基本用法:
docker + 命令关键字(COMMON)+ 一系列参数
2. docker 基础命令
原文:https://www.cnblogs.com/sswind/p/12172617.html