您的位置:首页 > 运维架构 > Docker

LinuxMint下Docker的安装部署和验证

2015-10-27 23:34 891 查看
通过lsb_release命令查看以下我的LinuxMint发行版,



查看以下我的Linux内核版本,



Docker要求Linux内核版本必须在要在3.10以上,显然我们的系统是满足的。

1. Docker安装

操作系统默认的apt源有docker包,我们可以直接使用下面的apt-get命令安装docker,

$ sudo apt-get install -y docker.io


不过其安装的版本比较老。我们采用下面两种方式进行安装,个人比较推荐第二种,第二种方式安装的是最新的。

1.1 从Docker的apt源安装

参考网页https://get.docker.com/ubuntu/内容进行安装,为方便直接将内容复制如下,


# Check that HTTPS transport is available to APT
if [ ! -e /usr/lib/apt/methods/https ]; then
apt-get update
apt-get install -y apt-transport-https
fi

# Add the repository to your APT sources
echo deb https://get.docker.com/ubuntu docker main > /etc/apt/sources.list.d/docker.list

# Then import the repository key
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9

# Install docker
apt-get update
apt-get install -y lxc-docker


目前从Docker的apt源安装的docker版本是1.7.1。

1.2 curl安装

网站https://get.docker.com提供了curl-able的安装脚本install.sh,我们可以通过curl的方式进行安装docker。我们先安装curl,

$ sudo apt-get update
$ sudo apt-get install curl


然后运行下面命令安装docker,

$ curl -k -sSl https://get.docker.com | sudo sh


该方式安装的docker版本是1.8.3,如下所示,



2. Docker验证

Docker安装结束后,我们来验证以下docker的功能。官方的Docker Hub提供了hello-world的镜像,我们可以通过该镜像起一个容器来验证我们已正确安装了docker。

lienhua34@lienhua34-Compaq-Presario-CQ35-Notebook-PC ~ $ sudo docker run hello-world

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.
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 Hub account: https://hub.docker.com 
For more examples and ideas, visit: https://docs.docker.com/userguide/[/code] 
出现上面打印信息表示,docker已正常工作。

3. 后记

有了docker之后,我们如果验证某些linux下的功能,而有不希望污染到我们的主机环境。那么我们就可以起一个linux环境的容器,然后在里面进行操作。操作结束后,就直接将容器杀掉即可。安全、方便、快捷!

例如下面启动一个Ubuntu 14.04的容器,并直接进入该容器,然后我们就可以在该容器里随便进行操作了。

$ sudo docker run -ti --name myubuntu ubuntu:14.04




(done)

**版本声明:该博文为博主原创,如需转载,请事先征求博主同意。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: