安装docker
CentOS 7 (使用yum进行安装)
# step 1: 安装必要的一些系统工具
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# Step 2: 添加软件源信息
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# Step 3: 更新并安装 Docker-CE
sudo yum makecache fast
sudo yum -y install docker-ce
# Step 4: 开启Docker服务
sudo service docker start
使用aliyun加速器
去aliyun开通镜像仓库:
https://cr.console.aliyun.com
使用aliyun加速:
mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://fgl80ig9.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
cat /etc/docker/daemon.json
{"registry-mirrors": ["https://fgl80ig9.mirror.aliyuncs.com","http://04be47cf.m.daocloud.io"]}
aliyun私有仓库:
# docker login --username=zmjllj@163.com registry.cn-hangzhou.aliyuncs.com
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
对应aliyun打标签:
# docker tag wordpress/v1:self registry.cn-hangzhou.aliyuncs.com/zhongmj/test:latest
上传镜像:
# docker push registry.cn-hangzhou.aliyuncs.com/zhongmj/test:latest
The push refers to repository [registry.cn-hangzhou.aliyuncs.com/zhongmj/test]
14d1cebf2db8: Pushed
1fe3bf02e29b: Pushed
4e215657d0fe: Pushed
b8500ad46143: Pushed
d7447f749047: Pushed
b3c5183b2d97: Pushed
504f84a2c59e: Pushed
d69483a6face: Pushed
latest: digest: sha256:c7ecac75643e79d7f66b4a2eabc09805c8404b658fb33e9fcca12ed7c0901826 size: 1993
拉取镜像:
# docker pull registry.cn-hangzhou.aliyuncs.com/zhongmj/test:latest
latest: Pulling from zhongmj/test
Digest: sha256:c7ecac75643e79d7f66b4a2eabc09805c8404b658fb33e9fcca12ed7c0901826
Status: Downloaded newer image for registry.cn-hangzhou.aliyuncs.com/zhongmj/test:latest