资源01: Docker官网
资源02: Docker Store
资源03: Ubuntu版本的Docker安装(参考这个)
资源04: Docker-compose安装(参考这个)

资源05: 阿里云开发者平台
资源06: 阿里云镜像加速器
资源07: docker中文版
资源08: 参考学习DNMP(Docker + Nginx + MySQL + PHP7/5)
安装时间: 2018-09-12 20:48

第1步:卸载旧版本的docker

vagrant@qianjin:~$ sudo apt-get remove docker docker-engine docker.io
//手工删除/var/lib/docker/, 里面有图象、容器、卷和网络. Docker现在的名字叫docker-ce.

第2步:安装docker-ce

vagrant@qianjin:~$  sudo apt-get update
sudo apt-get install  apt-transport-https ca-certificates software-properties-common

第3步:安装官方的 GPG key

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
vagrant@qianjin:~$ sudo apt-key fingerprint 0EBFCD88
pub   rsa4096 2017-02-22 [SCEA]
      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid           [ unknown] Docker Release (CE deb) <docker@docker.com>
sub   rsa4096 2017-02-22 [S]

第4步 安装docker-ce

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce
//docker --version 查看版本
//docker info

第5步 安装docker-compose

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

第6步 使用非root账号管理Docker

参考:https://docs.docker.com/insta...

vagrant@qianjin:~$ sudo groupadd docker
vagrant@qianjin:~$ sudo usermod -aG docker $USER
// 重启生效

第7步 使用国内阿里云镜像仓库加速器

参考: 登录dev.aliyun.com,在管理中心/镜像加速器中有
您可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://d7xucqac.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

第8步 运行第一个容器hello world

vagrant@qianjin:/etc$ docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

第9步 配置Docker开机自启动

ubuntu16及以上使用systemd管理服务的开机启动

vagrant@qianjin:~$ sudo systemctl enable docker
Synchronizing state of docker.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable docker

附件: 了解ca-certificates

SSL证书的维护由ca-certificates来提供支持
A: 根证书列表:/etc/ca-certificates.conf
B: 根证书存放位置:/usr/share/ca-certificates/mozilla[机构名]/Amazon_Root_CA_2[证书名].crt
C: SSL引用的证书的位置/etc/ssl/certs/xxxx.pem---->/usr/share/ca-certificates/xxx机构/xxxx.crt
D: 当/usr/share/ca-certificates目录下有变动的时候,/usr/sbin/update-ca-certificates根据/etc/ca-certificates.conf中的名字,创建/etc/ssl/certs/xxxx.pem软链接


advance100
599 声望80 粉丝

0he1.com在线课堂