软创互联

Docker安装

docker

#1

本贴收集整理docker的安装及初始配置说明。


以下说明来自 顾伟总结的

配置ubuntu仓库为网易镜像站

1、查看/etc/lsb-release/etc/issue.net文件内容,得到ubuntu版本信息;

cat /etc/lsb-release

2、备份/etc/apt/sources.list文件:

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak20180329

3、以ubuntu 16.04为例,新建/etc/apt/sources.list文件,内容如下:

deb http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse

4、执行更新:

sudo apt-get update

安装、配置docker

1、安装docker.io和docker-compose:

sudo apt-get install docker.io docker-compose

2、将用户ubuntu加入docker组,实现对docker的管理:

sudo gpasswd -a ubuntu docker

3、重启docker服务:

sudo systemctl restart docker

4、ubuntu用户退出系统后重新登陆,执行docker info命令,查看docker信息;
5、为加快镜像下载速度,通过Docker中国官方镜像加速(详见:https://www.docker-cn.com/registry-mirror ),新建/etc/docker/daemon.json文件,内容如下:

{
 "registry-mirrors": ["https://registry.docker-cn.com"]
}

7、更新配置:

sudo systemctl daemon-reload

8、重启Docker服务:

sudo systemctl restart docker

9、测试是否能够成功拉取hello-world镜像:

docker pull hello-world

ubuntu 14.04 & 15.04

https://docs.docker.com/install/linux/docker-ce/ubuntu/Trusty 14.04

apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual
apt-get update
apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
apt-key fingerprint 0EBFCD88 # 查询指纹
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update
apt-get install docker-ce
adduser ubuntu #密码 ggd!QAZ2wsx
usermod -aG docker ubuntu
https://docs.docker.com/compose/install/
curl -L https://github.com/docker/compose/releases/download/1.21.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version

于存档 #2

于解除存档 #3