hanshileiai
5/31/2018 - 2:19 AM

ubuntu 安装 docker

ubuntu 安装 docker ,不同系统不同安装方法

docker install

ubuntu 15.10 (docker 1.12)

sudo apt-get remove docker docker-engine
sudo curl -s 'https://sks-keyservers.net/pks/lookup?op=get&search=0xee6d536cf7dc86e2d7d56f59a178ac6c6238f52e' | sudo apt-key add --import
sudo apt-get update && sudo apt-get install apt-transport-https
sudo apt-get install -y linux-image-extra-virtual
echo "deb https://packages.docker.com/1.12/apt/repo ubuntu-wily main" | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt-get update
sudo apt-get upgrade docker-engine
sudo docker -v

ubuntu 14.04,16.04 (docker 18)

sudo apt-get remove docker docker-engine docker-ce
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-cache policy docker-ce
sudo apt-get install -y docker-ce
sudo docker -v

docker-compose install

sudo curl -o /usr/local/bin/docker-compose -L "https://github.com/docker/compose/releases/download/1.15.0/docker-compose-$(uname -s)-$(uname -m)"
sudo chmod +x /usr/local/bin/docker-compose
sudo docker-compose -v

docker-compose tailf logs

sudo docker-compose logs --tail=0 --follow

QA

如果以上操作在ubuntu 14.04上安装docker最新版本失败,建议安装老版本 docker 1.12 兼容

Ubuntu 14.04

sudo add-apt-repository \
   "deb https://packages.docker.com/1.12/apt/repo/ \
   ubuntu-$(lsb_release -cs) \
   main"
sudo apt-get update
sudo apt-get upgrade docker-engine
sudo docker -v

取消 sudo docker ,直接使用 docker 命令

sudo groupadd docker
sudo gpasswd -a ubuntu docker
sudo service docker restart