LinuxMint下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 Dockerapt源安裝

參考網頁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

目前從Dockerapt源安裝的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)

 

**版本聲明:該博文為博主原創,如需轉載,請事先征求博主同意。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM