Docker Hub 的服务器在国外,比较慢,可以用 DaoCloud.io免费的国内镜像服务,官方参考https://docs.docker.com/engine/installation/
环境:Docker Engine + runc + Ubuntu1804lts
检查服务器版本
uname -a
cat /proc/version
lsb_release -a
移除旧版本
apt-get remove docker docker-engine docker-ce docker.io
安装新版本,使apt可以通过HTTPS使用存储库(repository)
apt-get update
apt-get install -y apt-transport-https ca-certificates curl software-properties-common
Install packages to allow apt to use a repository over HTTPS
apt-get install \
> apt-transport-https \
> ca-certificates \
> curl \
> software-properties-common
添加Docker官方的GPG密钥
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
如果Ubuntu 18.04 LTS (Bionic Beaver) docker package is not available,则通过如下语句安装stable存储库
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu artful stable"
安装docker-ce
apt-get install -y docker-ce
也可查看可用版本并安装
apt-cache madison docker-ce
apt-get install docker-ce=<VERSION>
查看服务和启动
systemctl status docker
systemctl start docker
systemctl restart docker.service
测试Hello World
docker run hello-world
查看本地Docker镜像库
docker images
安装Apache并测试http://IP
docker run -d -p 80:80 httpd