Docker

Docker

官网 https://www.docker.com/
安装 https://docs.docker.com/v17.09/engine/installation/linux/docker-ce/ubuntu/#docker-ee-customers
镜像市场 http://hub.docker.com
教程 https://www.runoob.com/docker/docker-tutorial.html
国内高速下载Docker 以及 docker-compose 地址
http://get.daocloud.io
https://blog.csdn.net/nklinsirui/article/details/80610058

Aliyun Ubuntu 14.04/16.04(使用 apt-get 进行安装)

# step 1: 安装必要的一些系统工具
sudo apt-get update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
# step 2: 安装GPG证书
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
# Step 3: 写入软件源信息
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
# Step 4: 更新并安装Docker-CE
sudo apt-get -y update
sudo apt-get -y install docker-ce

# 安装指定版本的Docker-CE:
# Step 1: 查找Docker-CE的版本:
# apt-cache madison docker-ce
#   docker-ce | 17.03.1ce-0ubuntu-xenial | http://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 Packages#   docker-ce | 17.03.0ce-0ubuntu-xenial | http://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 Packages
# Step 2: 安装指定版本的Docker-CE: (VERSION例如上面的17.03.1ce-0ubuntu-xenial)
# sudo apt-get -y install docker-ce=[VERSION]

Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket.

#使用快速安装ubuntu 18
sudo apt install docker.io

增加配制:自己的仓库地址,镜像仓库地址X需更改,使用systemd与K8s同样配制

增加配制:3自己的仓库地址,镜像仓库地址X需更改,使用systemd与K8s同样配制 /etc/docker/daemon.json
{
 "insecure-registries":["harbor.com","192.168.88.128:5000"],
 "registry-mirrors":["https://cuzn52fX.mirror.aliyuncs.com","https://reg-mirror.qiniu.com","https://registry.docker-cn.com"],
 "exec-opts": ["native.cgroupdriver=systemd"],
 "storage-driver": "overlay2",
 "storage-opts": ["overlay2.override_kernel_check=true"],
 "log-driver": "json-file",
 "log-opts": {
    "max-size": "100m",
    "max-file": "3"
    },
 "max-concurrent-downloads": 5,
  "max-concurrent-uploads": 5
}

# 将Docker加入开启启动
$ sudo systemctl enable docker
# 启动Docker
$ sudo systemctl start docker
systemctl daemon-reload 重新加载
systemctl restart docker 重启docker

建立Docker用户组
默认情况下,docker命令会使用Unix Socket与Docker引擎通信,只有root用户和docker组的用户才可以访问Docker引擎的Unix Socket。出于安全考虑,一般不会直接使用root用户,所以需要先建立docker组,并将当前用户添加到docker组中。
$ sudo groupadd docker
$ sudo usermod -aG docker $USER

docker info

docker version

docker ps -a

docker images

docker exec -it container-id /bin/bash       exit

docker logs -f container-id

docker stop -f container-id

docker rmi Image-file

docker rm container-id

docker login

bocker build -t coustName:tag .

bocker build -t coustName:tag -f path

docker tag mysql:5.6 myreg/mysql:1.0

docker push myreg/mysql:1.0

Dockerfile

常用其它镜像地址:

七牛 quay-mirror.qiniu.com

卸载旧版本:

sudo systemctl stop docker
sudo apt-get purge docker-ce

sudo apt-get remove docker docker-ce docker-io

You must be logged in to post a comment