Docker在Ubuntu中安装

745 阅读1分钟

安装前的检查

# 内核版本
uname -a

# Device Mapper(存储驱动)
ls -l /sys/class/misc/device-mapper


Ubuntu中安装Docker的方式

  1. Ubuntu维护的版本(不推荐)
  2. Docker维护的版本(推荐)

安装Ubuntu维护的版本

sudo apt-get install docker.io
source /etc/bash_completion.d/docker.io

sudo docker.io version

安装Docker维护的版本

# 1. 检查APT的HTTPS支持
# 查看/usr/lib/apt/methods/https文件是否存在
apt-get update
apt-get install -y apt-transport-https

# 2. 添加Docker的APT仓库
echo deb https://get.docker.com/ubuntu docker main > /etc/apt/sources.list.d/docker.list

# 3. 添加仓库的key

# 4. 安装
apt-get update
apt-get install -y lxc-docker

简易安装方式
docs.docker.com/install/lin…

# 安装curl
sudo apt-get install -y curl

# 下载安装脚本并安装
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

# 查看docker版本
docker version

使用非root用户

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


输出hello world

sudo docker pull ubuntu
sudo docker run ubuntu echo "hello world"