【Docker】Docker启动验证

通过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/

出现上面打印信息表示,docker已正常工作。

3. 后记

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

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

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

(done)

更多Docker相关教程见以下内容

Docker安装应用(CentOS 6.5_x64) http://www.linuxidc.com/Linux/2014-07/104595.htm

Ubuntu 14.04安装Docker  http://www.linuxidc.com/linux/2014-08/105656.htm

Ubuntu使用VNC运行基于Docker的桌面系统  http://www.linuxidc.com/Linux/2015-08/121170.htm

阿里云CentOS 6.5 模板上安装 Docker http://www.linuxidc.com/Linux/2014-11/109107.htm

Ubuntu 15.04下安装Docker  http://www.linuxidc.com/Linux/2015-07/120444.htm

在Ubuntu Trusty 14.04 (LTS) (64-bit)安装Docker http://www.linuxidc.com/Linux/2014-10/108184.htm

在 Ubuntu 15.04 上如何安装Docker及基本用法 http://www.linuxidc.com/Linux/2015-09/122885.htm

Ubuntu 16.04上Docker使用手记 http://www.linuxidc.com/Linux/2016-12/138490.htm

Docker 的详细介绍请点这里
Docker 的下载地址请点这里

本文永久更新链接地址http://www.linuxidc.com/Linux/2017-02/141147.htm

原文地址:https://blog.csdn.net/qq_22616665/article/details/73478409

猜你喜欢

转载自blog.csdn.net/wzl505/article/details/81104007
今日推荐