使用平臺
目前docker僅支持64位環境下安裝
- Ubuntu
- Debian
- RHEL系列
- centos
- Fedora
Ubuntu環境
更新內核
查看版本:
uname -a
更新為3.8內核:
apt-get install linux-headers-3.13.0-43-generic linux-image-3.13.0-43-generic linux-headers-3.13.0-43
更新Ubuntu啟動加載器:
update-grub
init 6
檢查Device Mapper
這里將Device Mapper作為存儲驅動,自2.6.9內核之后就已經繼承了這個驅動。這里檢查一下:
ls -lh /sys/class/misc/device-mapper
或者
grep device-mapper /proc/device
如果沒有就加載:
modprobe dm-mod
自2.6版本內核之后就對命名空間提供了良好的支持,不必糾結
安裝docker
添加APT倉庫:
echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" > /etc/apt/sources.list.d/docker.list
apt-get update
應該將trusty改為Ubuntu發行版本,查看版本:
lsb_release --codename | cut -f2
自docker1.8.0開始,docker的軟件包名稱從lxc-docker
變為了docker-engine
查看并安裝:
apt list | grep docker-engine
apt-get install docker-engine
docker info
命令查看是否正常:
root@doushuo-virtual-machine:~# docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 17.05.0-ce
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 0
Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9048e5e50717ea4497b757314bad98ea3763c145
runc version: 9c2d8d184e5da67c95d601382adf14862e4f2228
init version: 949e6fa
Security Options:
apparmor
Kernel Version: 3.19.0-25-generic
Operating System: Ubuntu 14.04.3 LTS
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 976.8MiB
Name: doushuo-virtual-machine
ID: HC3O:RZVT:6MFM:LJN5:RXC5:BUKQ:OGYH:MGP7:6BAJ:QP3Q:FGWV:XDGN
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No swap limit support
docker與UFW
在Ubuntu中,如果使用的是UFW防火墻,默認UFW會丟棄所有轉發的數據包,docker使用網橋對各個容器進行管理。我們需要修改UFW的配置:
root@doushuo-virtual-machine:~# grep "DEFAULT_FORWARD_POLICY"
DEFAULT_FORWARD_POLICY="DROP"
修改規則為ACCEPT
Red Hat及其發行版的環境
環境支持
- REHL/centos 6及其以上的版本
- Fedora 19及其以上的版本
- Oracle Linux 6和Oracle Linux7,帶有Unbreakable企業內核發行版3(3.8.13)及其以上的版本
檢查內核版本
uname -a
Linux localhost.localdomain 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
目前所有官方支持的Redhat及其系列平臺,應該都安裝了支持docker的內核
檢查Device Mapper
grep device-mapper /proc/device
沒有就安裝,安裝完成后加載Device Mapper模塊:
yum install -y device-mapper
modprobe dm-mod
安裝docker
Redhat中,不通發行版安裝過程略有不同,在這只考慮Redhat和centos環境
Redhat6/centos6:
rpm -Uvh http://download.fadoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
yum -y install docker-io
Redhat7:
subscription-manager repos --enable-rhel-7-server-extras-rpms
yum install -y docker
centos7 啟動docker
systemctl start docker
docker info
centos7 開機自啟動
systemctl enable docker
或者
chkconfig docker on
Docker用戶界面
安裝docker之后,也可以使用圖形的用戶界面進行管理,有一些正在開發中的docker用戶界面和web控制臺:
- Shipyard:https://github.com/ehazlett/shipyard
- DockerUI
- Kitematic:在Windows和OS X下使用的GUI界面工具,由docker公司免費發布的產品,包含于docker toolbox之中