www.icesr.com
IT运维工程师的摇篮

Docker的安装

一:关于docker

Docker 是一个开源项目,诞生于 2013 年初,最初是 dotCloud 公司内部的一个业余项目。它基于 Google 公司推出的 Go 语言实现。 项目后来加入了 Linux 基金会,遵从了 Apache 2.0 协议,项目代码在 GitHub 上进行维护。

Docker 项目的目标是实现轻量级的操作系统虚拟化解决方案。 Docker 的基础是 Linux 容器(LXC)等技术。

在 LXC 的基础上 Docker 进行了进一步的封装,让用户不需要去关心容器的管理,使得操作更为简便。用户操作 Docker 的容器就像操作一个快速轻量级的虚拟机一样简单。

摘自:
http://dockerpool.com/static/books/docker_practice/introduction/what.html

二:安装centos

在使用virtualbox安装的时候需要把网络修改成【Bridged A’dapter】,方便获得上网ip,ssh连接到虚拟机。
centos7 可以直接使用yum 安装docker
最懒的方式,只是为了学习docker省去了折腾环境的麻烦。
直接使用iso进行安装就行了。

三:安装docker

直接安装就可以了: yum install golang docker device-mapper-event-libs

必须安装 device-mapper-event-libs 否则docker启动不了,报错:Failed to start Docker Application Container Engine。
配置&启动服务

<code><span class="hljs-number">1</span><span class="hljs-symbol">:systemctl</span> enable docker
<span class="hljs-number">2</span><span class="hljs-symbol">:systemctl</span> start docker</code>

docker服务就可以正常启动了。

四:docker hello world

虚拟安装一个MySQL,docker非常强大的时image。在官方搜索类库非常多。
https://registry.hub.docker.com/search?q=library
docker的注册中心,里面有很多做好的镜像库。
mysql的安装:
/mysql/”>https://registry.hub.docker.com//mysql/

安装mysql过程,设置数据库docker-mysql,版本5.5

<code><span class="hljs-number">1</span>:<span class="hljs-comment"># docker run --name docker-mysql -e MYSQL_ROOT_PASSWORD=docker-mysql -d mysql:5.5</span>
<span class="hljs-number">2</span>:Unable to find image <span class="hljs-string">'mysql:5.5'</span> locally
<span class="hljs-number">3</span>:Trying to pull repository docker.io/mysql <span class="hljs-keyword">...</span>
<span class="hljs-number">4</span>:2f08318d65b3: Pulling dependent layers 
<span class="hljs-number">5</span>:511136ea3c5a: Download complete 
<span class="hljs-number">6</span>:4f903438061c: Download complete 
<span class="hljs-number">7</span>:1265e16d0c28: Download complete 
<span class="hljs-number">8</span>:ac1d5afd7b69: Download complete 
<span class="hljs-number">9</span>:7c89455832dd: Downloading [===========================&gt;                       ] <span class="hljs-number">4.434</span> MB/<span class="hljs-number">8.077</span> MB 34s</code>

查看docker镜像:

<code>docker ps <span class="hljs-operator">-a</span>
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS               NAMES
e59ad4702626        mysql:<span class="hljs-number">5.5</span>           <span class="hljs-string">"/entrypoint.sh mysq   2 minutes ago       Up 2 minutes        3306/tcp            docker-mysql</span></code>

查看mysql的docker服务器,直接登录到mysql容器,就安装好了mysql。同时服务也启动了,测试mysql docker启动成功。

<code>docker exec -<span class="hljs-keyword">it</span> docker-mysql bash

<span class="hljs-number">1</span> docker exec -<span class="hljs-keyword">it</span> docker-mysql bash
<span class="hljs-number">2</span> root@e59ad4702626:/<span class="hljs-comment"># mysql -uroot -pdocker-mysql</span>
<span class="hljs-number">3</span> Welcome <span class="hljs-keyword">to</span> <span class="hljs-keyword">the</span> MySQL monitor.  Commands <span class="hljs-keyword">end</span> <span class="hljs-keyword">with</span> ; <span class="hljs-keyword">or</span> /g.
<span class="hljs-number">4</span> Your MySQL connection <span class="hljs-property">id</span> <span class="hljs-keyword">is</span> <span class="hljs-number">5</span>
<span class="hljs-number">5</span> Server <span class="hljs-property">version</span>: <span class="hljs-number">5.5</span><span class="hljs-number">.43</span> MySQL Community Server (GPL)
<span class="hljs-number">6</span> 
<span class="hljs-number">7</span> Copyright (c) <span class="hljs-number">2000</span>, <span class="hljs-number">2015</span>, Oracle <span class="hljs-keyword">and</span>/<span class="hljs-keyword">or</span> <span class="hljs-keyword">its</span> affiliates. All rights reserved.
<span class="hljs-number">8</span>
<span class="hljs-number">9</span> Oracle <span class="hljs-keyword">is</span> a registered trademark <span class="hljs-keyword">of</span> Oracle Corporation <span class="hljs-keyword">and</span>/<span class="hljs-keyword">or</span> <span class="hljs-keyword">its</span>
<span class="hljs-number">10</span> affiliates. Other names may be trademarks <span class="hljs-keyword">of</span> their respective
<span class="hljs-number">11</span> owners.
<span class="hljs-number">12</span>
<span class="hljs-number">13</span> Type 'help;' <span class="hljs-keyword">or</span> '/h' <span class="hljs-keyword">for</span> help. Type '/c' <span class="hljs-keyword">to</span> clear <span class="hljs-keyword">the</span> current input statement.
<span class="hljs-number">14</span>
<span class="hljs-number">15</span> mysql&gt; show databases;
<span class="hljs-number">16</span> +<span class="hljs-comment">--------------------+</span>
<span class="hljs-number">17</span> | Database           |
<span class="hljs-number">18</span> +<span class="hljs-comment">--------------------+</span>
<span class="hljs-number">19</span> | information_schema |
<span class="hljs-number">20</span> | mysql              |
<span class="hljs-number">21</span> | performance_schema |
<span class="hljs-number">22</span> +<span class="hljs-comment">--------------------+</span>
<span class="hljs-number">23</span> <span class="hljs-number">3</span> rows <span class="hljs-keyword">in</span> <span class="hljs-keyword">set</span> (<span class="hljs-number">0.00</span> sec)
<span class="hljs-number">24</span>
<span class="hljs-number">25</span> mysql&gt; </code>

同时这个是一个虚拟的服务器,上面安装的mysql。

未经允许不得转载:冰点网络 » Docker的安装

分享到:更多 ()

评论 抢沙发

评论前必须登录!