linux下Docker安装
完整版Docker安装:
1、更新源
sudo vi /etc/apt/sources.list
内容:
#aliyun
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universemultiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universemultiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universemultiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universemultiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universemultiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universemultiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universemultiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universemultiverse
sudo apt-get update
2、删除旧版本Docker(如果以前安装过)
sudo apt-get remove docker docker-enginedocker.io
3、安装系统依赖
sudo apt-get -y install \
linux-image-extra-$(uname -r) \
linux-image-extra-virtual
4、安装依赖
sudo apt-get -y install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
5、添加Docker官方GPG key(根据实际工作运用选择)
# Docker官方
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# 阿里云官方(自己工作是阿里云的)
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
6、验证安全指纹#(Docker官方)
# Docker官方
sudo apt-key fingerprint 0EBFCD88
7、添加官方镜像仓库
# Docker官方
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
# 阿里云官方
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
8、更新源
sudo apt-get -y update
9、安装Docker CE版
sudo apt-get install -y docker-ce
10、验证Docker安装成功
sudo docker run hello-world
输出如下成功:
Hello from Docker!
11、启动Docker
sudo service docker start
12、停止Docker
sudo service docker stop
13、卸载Docker
sudo apt-get purge docker-ce
14、删除容器、镜像
sudo docker rm 容器名
sudo docker rmi 镜像名
15、查看Docker信息
sudo docker info
16、查看Docker容器状态
sudo docker stats
17、查看Docker版本
sudo docker --version
或
sudo docker version
18、查看Docker镜像
sudo docker images
19、查看正在运行的容器
sudo docker ps
20、搜索远程仓库镜像
sudo docker search 镜像名
# 查看tags
https://hub.docker.com/
或
https://registry.hub.docker.com/v1/repositories/镜像名/tags
# 例如:
https://registry.hub.docker.com/v1/repositories/ubuntu/tags
21、删除镜像
sudo docker rmi 镜像名
# 例如:
sudo docker rmi hello-world
sudo docker rmi ubuntu:14.04
本人阿里云运用版:
安装系统依赖:
sudo apt-get -y install linux-image-extra-$(uname -r) linux-image-extra-virtual
安装依赖:
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
添加Docker阿里云官方:
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
阿里云官方:
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
更新源:
sudo apt-get -y update
安装Docker CE版:
sudo apt-get install -y docker-ce