Docker是一个用于搭建虚拟环境的线上容器,可以在不影响主机环境的情况下,安装基于不同环境的上层应用。
准备
检查内核版本是否大于3.10
1 |
uname -r |
安装依赖组件CURL
1 2 |
apt-get update apt-get install curl |
安装Docker
使用apt包管理器安装
安装apt加密证书组件
1 |
apt-get install apt-transport-https ca-certificates software-properties-common |
将输出
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
root@vps:~# apt-get install apt-transport-https ca-certificates software-properties-common Reading package lists... Done Building dependency tree Reading state information... Done apt-transport-https is already the newest version. ca-certificates is already the newest version. The following extra packages will be installed: gir1.2-glib-2.0 libdbus-glib-1-2 libgirepository-1.0-1 libglib2.0-0 libglib2.0-data python3-apt python3-dbus python3-gi python3-software-properties shared-mime-info unattended-upgrades xdg-user-dirs Suggested packages: python3-apt-dbg python-apt-doc python-dbus-doc python3-dbus-dbg The following NEW packages will be installed: gir1.2-glib-2.0 libdbus-glib-1-2 libgirepository-1.0-1 libglib2.0-0 libglib2.0-data python3-apt python3-dbus python3-gi python3-software-properties shared-mime-info software-properties-common unattended-upgrades xdg-user-dirs 0 upgraded, 13 newly installed, 0 to remove and 8 not upgraded. Need to get 6682 kB of archives. After this operation, 22.5 MB of additional disk space will be used. |
添加Docker官方GPG Key
1 |
curl -fsSL https://yum.dockerproject.org/gpg | sudo apt-key add - |
以上命令将在/etc/apt/trusted.gpg中添加内容
验证GPG Key
1 |
apt-key fingerprint 58118E89F3A912897C070ADBF76221572C52609D |
下方应找到对应fingerprint
1 2 3 |
pub 4096R/2C52609D 2015-07-14 Key fingerprint = 5811 8E89 F3A9 1289 7C07 0ADB F762 2157 2C52 609D uid Docker Release Tool (releasedocker) <docker@docker.com> |
添加Docker官方源
1 |
add-apt-repository "deb https://apt.dockerproject.org/repo/ debian-$(lsb_release -cs) main" |
以上命令将在/etc/apt/sources.list中添加内容
安装最新Docker包
1 2 |
apt-get update apt-get -y install docker-engine |
将输出
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
root@vps:~# apt-get -y install docker-engine Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: aufs-tools cgroupfs-mount libdrm2 libnih-dbus1 libnih1 makedev mountall plymouth Suggested packages: desktop-base plymouth-themes The following NEW packages will be installed: aufs-tools cgroupfs-mount docker-engine libdrm2 libnih-dbus1 libnih1 makedev mountall plymouth 0 upgraded, 9 newly installed, 0 to remove and 8 not upgraded. Need to get 19.6 MB of archives. After this operation, 89.7 MB of additional disk space will be used. |
OR安装指定版本Docker包
查看目前的包版本
1 |
apt-cache madison docker-engine |
安装指定版本
1 |
apt-get -y install docker-engine=<VERSION_STRING> |
验证Docker是否成功安装
1 |
docker run hello-world |
成功运行后会显示如下信息
1 2 3 4 5 6 7 8 9 10 |
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. |
卸载Docker
卸载Docker包
1 |
apt-get purge docker-engine |
删除库文件
1 |
rm -rf /var/lib/docker |
There are no comments yet