Docker: 仓库管理

docker respository

分为公共仓库与私有仓库两种。

  • 注册服务器 registry: 存放仓库的具体服务器,可容纳多个仓库
  • 仓库 regisitory: 存放镜像的一个具体的项目目录,可容纳多个镜像

example:

kumata-docker.com/test-image
// kumata-docker.com -> registry
// test-image -> regisitory

1. 公共镜像市场

Docker official address: https://hub.docker.com/

// login, it will create ~/.docker/config.json
docker login

// 基操
// 基础镜像/根镜像,一般为单个单词的名字
docker pull centos
// 用户创建并维护,一般为 用户名/镜像名
docker pull hyperledger/explorer

2. 搭建本地私有仓库

  1. 自动下载并启动一个registry contain,默认创建在 /var/lib/registry 下:
// use registry create private regisitory
docker run -d -p 5000:5000 registry:2

// -v 指定位置
docker run -d -p 5000:5000 -v /opt/data/registry:/var/lib/registr registry:2
  1. 管理私有仓库
// watch
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest f643c72bc252 12 days ago 72.9MB
// add tag to image 
docker tag ubuntu:latest 10.8.9.40:5000/ubuntu_test
REPOSITORY TAG IMAGE ID CREATED SIZE
10.8.9.40:5000/ubuntu_test latest f643c72bc252 12 days ago 72.9MB

Add http config

sudo vim /etc/docker/daemon.json
// add
{"insecure-registries":["10.8.9.40:5000"]}
// restart docker
sudo systemctl daemon-reload
sudo systemctl restart docker

push and pull

// push to registory
docker push 10.8.9.40:5000/ubuntu_test

// pull image
docker pull 10.8.9.40:5000/ubuntu_test

// if need, add tag:
docker tag 10.8.9.40:5000/ubuntu_test ubuntu_kumata:18.04
posted @ 2020-12-08 18:01  kumata  阅读(184)  评论(0编辑  收藏  举报