Docker(二)-Docker安裝

官方文檔:https://docs.docker.com/

Docker 支持多平臺的安裝(Linux/Windows/OS X)。

因爲Docker原生支持Linux,所以,可以直接在Linux上運行,而且在Windows和 OS X 平臺則需要藉助輕量級的 Linux VM 運行。

Ubuntu在線安裝docker


在Ubuntu上安裝Docker的說明取決於您使用的是Docker企業版(Docker EE)還是Docker社區版(Docker CE)。

參考文檔:https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/

使用倉庫進行安裝

首次在新的主機上安裝Docker CE之前,需要設置Docker倉庫。 之後,你可以從存儲庫安裝和更新Docker。

設置倉庫

1、更新 apt 包索引:

$ sudo apt-get update

2、安裝軟件包,使它允許apt通過HTTPS使用倉庫:

$ sudo apt-get install apt-transport-https ca-certificates curl software-properties-common

3、添加Docker的官方GPG密鑰:

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

通過搜索密鑰的最後8個字符,確認您現在已經擁有指紋 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 的密鑰。

$ sudo apt-key fingerprint 0EBFCD88

pub 4096R/0EBFCD88 2017-02-22
密鑰指紋 = 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid Docker Release (CE deb) <[email protected]>
sub 4096R/F273FCD8 2017-02-22

4、使用以下命令來設置 stable 的倉庫。即使你想從 __edge __ 或 test 倉庫安裝構建,也總是需要 stable 的倉庫。要添加 __edge __ 或 test 倉庫,請在下面的命令中在單詞stable之後添加edge或test(或兩者)。

$ sudo add-apt-repository \
  "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

注意:上面的lsb_release -cs子命令返回你的Ubuntu發行版的名字,比如xenial。

安裝Docker CE

1、更新 apt 包索引:

$ sudo apt-get update

2、安裝最新版本有 Dcoker CE

$ sudo apt-get install docker-ce

3、在生產系統上,您應該安裝特定版本的Docker CE,而不是始終使用最新版本。下面命令列出可用的版本。

$ apt-cache madison docker-ce

docker-ce | 17.12.0ce-0ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.09.1ce-0ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.09.0ce-0ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.06.2ce-0ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.06.1ce-0ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.06.0ce-0ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.03.2ce-0ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.03.1ce-0ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
docker-ce | 17.03.0ce-0ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages

安裝指定的版本:

$ sudo apt-get install docker-ce=<VERSION>

4、通過運行hello-world 鏡像驗證Docker CE是否正確安裝。

$ sudo docker run hello-world

Unable to find image ‘hello-world:latest’ locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:66ef312bbac49c39a89aa9bcc3cb4f3c9e7de3788c944158df3ee0176d32b751
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 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 ID:
https://cloud.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/

其它

查看 Docker 版本:

$ sudo docker version

Client:
Version: 17.12.0-ce
API version: 1.35
Go version: go1.9.2
Git commit: c97c6d6
Built: Wed Dec 27 20:11:19 2017
OS/Arch: linux/amd64

Server:
Engine:
Version: 17.12.0-ce
API version: 1.35 (minimum version 1.12)
Go version: go1.9.2
Git commit: c97c6d6
Built: Wed Dec 27 20:09:53 2017
OS/Arch: linux/amd64
Experimental: false

顯示 Docker 系統信息,包括鏡像和容器數:

$ sudo docker info

Containers: 7
Running: 0
Paused: 0
Stopped: 7
Images: 2
Server Version: 17.12.0-ce
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 20
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 89623f28b87a6004d4b785663257362d1658a729
runc version: b2567b37d7b75eb4cf325b77297b140ea686ce8f
init version: 949e6fa
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.13.0-26-generic
Operating System: Ubuntu 16.04.3 LTS
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.924GiB
Name: ubuntu
ID: OXZY:HYGR:X6XJ:CLDF:H2UG:KXCY:J6MD:32WV:UORN:E2QY:TRTL:ISI6
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false

WARNING: No swap limit support


Ubuntu離線安裝docker


 安裝依賴組件

更新apt-get源

sudo echo 'deb http://cz.archive.ubuntu.com/ubuntu trusty main' | sudo tee /etc/apt/sources.list

sudo apt-get update

 

安裝libsystemd-journal0

sudo apt-get install -y libsystemd-journal0

 

安裝libltdl7_2.4.6

sudo wget http://launchpadlibrarian.net/236916213/libltdl7_2.4.6-0.1_amd64.deb

sudo dpkg -i libltdl7_2.4.6-0.1_amd64.deb

 

安裝docker


 

sudo curl -O https://apt.dockerproject.org/repo/pool/main/d/docker-engine/docker-engine_1.12.5-0~ubuntu-trusty_amd64.deb

sudo dpkg -i  docker-engine_1.12.5-0~ubuntu-trusty_amd64.deb

 

安裝deb包 可以參考:ubuntu下安裝軟件的三種方法

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章