[TOC]
官方脚本安装
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
这里直接使用批量脚本,通过阿里云镜像安装,如果想掌握安装过程,需要继续往下看
使用阿里云镜像安装
参考官方文档 https://yq.aliyun.com/articles/110806?spm=5176.8351553.0.0.6a721991LqELWA
# step 1: 安装必要的一些系统工具
sudo apt-get update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
# step 2: 安装GPG证书
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
# Step 3: 写入软件源信息
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
# Step 4: 更新并安装 Docker-CE
sudo apt-get update
sudo apt-get -y install docker-ce
# 安装的版本可能很低,建议更换后面的方式安装
sudo apt-get -y install docker-compose
# python-pip
sudo apt-get -y install python-pip
# update pip
sudo pip install --upgrade pip
# install docker-compose
sudo pip install docker-compose
# Cannot uninstall 'texttable'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
sudo pip install docker-compose --ignore-installed texttable
# 安装指定版本的Docker-CE:
# Step 1: 查找Docker-CE的版本:
# apt-cache madison docker-ce
# docker-ce | 17.03.1~ce-0~ubuntu-xenial | http://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 Packages
# docker-ce | 17.03.0~ce-0~ubuntu-xenial | http://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 Packages
# Step 2: 安装指定版本的Docker-CE: (VERSION 例如上面的 17.03.1~ce-0~ubuntu-xenial)
# sudo apt-get -y install docker-ce=[VERSION]
16.04 安装
- set resource
# update package
sudo apt-get update
# Install packages
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
# add GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# set up the stable repository
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
- install docker-ce
sudo apt-get update
sudo apt-get install docker-ce
- Uninstall Docker CE
# Uninstall the Docker CE package
sudo apt-get purge docker-ce
# remove Images, containers, volumes, or customized configuration files
sudo rm -rf /var/lib/docker
tips: You must delete any edited configuration files manually
14.04安装docker
通过apt-get安装
apt-get update
apt-get install docker.io
ln -sf /usr/bin/docker.io /usr/local/bin/docker
sed -i '$acomplete -F _docker docker' /etc/bash_completion.d/docker.io
apt-get install apt-transport-https
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
apt-get update
apt-get install lxc-docker
通过下载二进制文件安装
curl -sSL https://get.docker.com/ | sh
安装过程输出
#查看index.htmlkkk@bogon:~$ sudo apt-get install vim
Reading package lists... Done
Building dependency tree
Reading state information... Done
vim is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 32 not upgraded.
kkk@bogon:~$ vi ./index.html
# 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.io/ubuntu docker main > /etc/apt/sources.list.d/docker.lis
t
# Then import the repository key
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F96
6E92D8576A8BA88D21E9
# Install docker
apt-get update
apt-get install -y lxc-docker
#
# Alternatively, just use the curl-able install.sh script provided at https://get.dock
er.io
#
~
"./index.html" 19L, 584C 1,1 All
# 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.io/ubuntu docker main > /etc/apt/sources.list.d/docker.lis
t
# Then import the repository key
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F96
6E92D8576A8BA88D21E9
# Install docker
apt-get update
apt-get install -y lxc-docker
#
# Alternatively, just use the curl-able install.sh script provided at https://get.dock
er.io
#
~
这种方式启动docker若出现下面错误,请安装apparmor软件
Error loading docker apparmor profile: fork/exec /sbin/apparmor_parser: no such file or directory ()
sudo apt-get install apparmor
安装后检查安装
sudo docker run hello-world
sudo docker pull daocloud.io/library/ubuntu:latest
去除每次sudo运行docker命令
需要添加组
# Add the docker group if it doesn't already exist.
$ sudo groupadd docker
#改完后需要重新登陆用户
$ sudo gpasswd -a ${USER} docker
# 更新用户组
$ newgrp docker
不要让docker 运行在 root 下,所以给某个用户 docker 运行权限是必要的
网友评论