首页 > 其他分享 >Docker(三):镜像仓库 - 公共仓库、私有仓库 - commit、tag、push

Docker(三):镜像仓库 - 公共仓库、私有仓库 - commit、tag、push

时间:2023-01-07 11:01:22浏览次数:37  
标签:ago 8080 仓库 ubuntu vim tag 镜像 commit docker

参考地址:https://blog.csdn.net/weixin_43526371/article/details/125828194

镜像分层 和 UnionFS
docker的镜像实际上由一层一层的文件系统组成,这种层级的文件系统就是UnionFS。

UnionFS是一种分层、轻量级并且高性能的文件系统。联合加载会把各层文件系统叠加起来,这样最终的文件系统会包含所有底层的文件和目录。

docker镜像可以通过分层来进行继承,基于基础镜像(没有父镜像),可以制作各种具体的应用镜像。

特性: 一次同时加载多个文件系统,但从外面看起来,只能看到一个文件系统,联合加载会把各层文件系统叠加起来,这样最终的文件系统会包含所有底层的文件和目录。

 

通过为容器添加vim功能来创建一个新的带vim功能的镜像
commit 命令生成镜像到本地

例:ubuntu添加vim功能并导出为新的镜像

$ docker images
# REPOSITORY TAG IMAGE ID CREATED SIZE
# mysql latest 33037edcac9b 2 days ago 444MB
# nginx latest 41b0e86104ba 3 days ago 142MB
# ubuntu latest 27941809078c 5 weeks ago 77.8MB

$ docker run -it ubuntu /bin/bash
# 进入到容器内

$ vim
# bash: vim: command not found

$ apt-get update # 更新包管理工具
# ··· ···
# Fetched 21.9 MB in 9s (2475 kB/s)
# Reading package lists... Done

$ apt-get -y install vim
# ··· ···

$ vim --version
# VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Apr 18 2022 19:26:30)
# ··· ···

$ Ctrl + p + q # 退出容器

$ docker ps
# CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
# e290dd267fe4 ubuntu "/bin/bash" 8 minutes ago Up 8 minutes laughing_diffie

# 提交生成新镜像到本地 docker commit -m="信息" -a="作者" 容器ID 镜像名:[标签名]
$ docker commit -m="==== add vim ====" -a="ProsperLee" e290dd267fe4 ubuntu_vim:v1

# 测试
$ docker run -it ubuntu_vim:v1 /bin/bash
$ vim --version
# VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Apr 18 2022 19:26:30)
# ··· ···

思考:
可在现有带有vim功能上的镜像基础上在添加其他功能生成新的镜像(形成一层一层的逐渐进行加强镜像)
提交本地镜像到线上仓库
$ docker login -u prosperlee -p ******
# WARNING! Using --password via the CLI is insecure. Use --password-stdin.
# 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

$ docker tag 294189a8321b prosperlee/ubuntu_vim # [:tag]
$ docker push prosperlee/ubuntu_vim # [:tag]
# Using default tag: latest
# The push refers to repository [docker.io/prosperlee/ubuntu_vim]
# 7f2a07241fd7: Pushed
# a790f937a6ae: Mounted from library/ubuntu
# latest: digest: sha256:f4c0537037ad7f9c2ee18fc6e5ca641daf4144e4d766f60afc7b31d918bb4f94 size: 741

$ docker pull prosperlee/ubuntu_vim

将本地镜像推送到私有库上(Docker Registry)
https://hub.docker.com/_/registry

# 拉取镜像
$ docker pull registry

# 运行镜像
$ docker run -d --name=registry -p 8080:5000 registry

# 创建daemon.json配置文件
$ touch /etc/docker/daemon.json

# 添加 { "insecure-registries": ["127.0.0.1:8080"] }
$ vi /etc/docker/daemon.json

# 如果推送不上去可以重启下docker试下 systemctl restart docker

# 查看目前仓库中存在哪些镜像 {"repositories":[]}
$ curl -XGET http://127.0.0.1:8080/v2/_catalog

# 运行ubuntu
$ docker run -it ubuntu /bin/bash

# 更新包管理工具
$ apt-get update

# 安装vim
$ apt-get -y install vim

# 查看当前运行的容器
$ docker ps
# CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
# 725b59e0d810 ubuntu "/bin/bash" 2 minutes ago Up 2 minutes wonderful_bohr
# d449838d77cb registry "/entrypoint.sh /etc…" 2 hours ago Up 2 hours 0.0.0.0:8080->5000/tcp, :::8080->5000/tcp registry
# 在本地创建一个属于自己的独一无二的镜像
$ docker commit -m="==== new ubuntu v1.0.0 ====" -a="ProsperLee" 725b59e0d810 lee/ubuntu:v1.0.0
# sha256:5530e920c230eddfd12665c4e7cf1cf472f002ef27eddc3e89b8a294163833be

# 查看镜像
$ docker images
# REPOSITORY TAG IMAGE ID CREATED SIZE
# lee/ubuntu v1.0.0 5530e920c230 58 seconds ago 172MB
# ubuntu latest 27941809078c 5 weeks ago 77.8MB
# registry latest 773dbf02e42e 7 weeks ago 24.1MB

# 标记本地镜像,将其归入某一仓库
$ docker tag 5530e920c230 127.0.0.1:8080/lee/ubuntu:v1.0.0

# push到私有库
$ docker push 127.0.0.1:8080/lee/ubuntu:v1.0.0

# 查看目前仓库中存在哪些镜像 {"repositories":["lee/ubuntu"]}
$ curl -XGET http://127.0.0.1:8080/v2/_catalog

# 查看私有库中镜像的tag {"name":"lee/ubuntu","tags":["v1.0.0"]}
$ curl -XGET http://127.0.0.1:8080/v2/lee/ubuntu/tags/list

# 拉取私有库中镜像
$ docker pull 127.0.0.1:8080/lee/ubuntu:v1.0.0

# 查看镜像
$ docker images
# REPOSITORY TAG IMAGE ID CREATED SIZE
# 127.0.0.1:8080/lee/ubuntu v1.0.0 5530e920c230 5 minutes ago 172MB

# 运行镜像
$ docker run -it 5530e920c230 /bin/bash

# 检查是否存在vim
$ vim --version

标签:ago,8080,仓库,ubuntu,vim,tag,镜像,commit,docker
From: https://www.cnblogs.com/js1314/p/17032242.html

相关文章

  • linux服务器做git仓库时,没有修改内容却提示有文件变动的解决方法
    老服务器迁移项目到新服务器后,之前的git拉取gitee仓库的功能是使用php脚本编写的,但是迁移后,一直会提示有文件被修改了,可是仔细对比了内容,包括换行符,都是没有问题的,之后......
  • .NETCore Docker实现容器化与私有镜像仓库管理
    一、Docker介绍Docker是用Go语言编写基于Linux操作系统的一些特性开发的,其提供了操作系统级别的抽象,是一种容器管理技术,它隔离了应用程序对基础架构(操作系统等)的依赖。相......
  • 推送自研包到python仓库
    环境Python版本:3.6.8仓库:JFrogArtifactory步骤包制作https://zhuanlan.zhihu.com/p/37987613.pypirc文件在$home目录下创建.pypirc文件从Artifactory平......
  • docker容器、仓库 二
    操作docker容器容器是docker的又一核心概念,基础一中介绍了镜像,容器时独立运行的一个或一组应用,以及他们的运行态环境,虚拟机可以理解为模拟运行的一整套操作系统和应......
  • docker提交容器成一个新的镜像commit和push,以及docker常用命令
    docker自己提交配置好的容器,然后生成一个新的镜像,以后启动就以配置好的镜像作为模板启动代码如下:dockercommit-a"author"-m"commitmessage"容器idnamespace/name:t......
  • com.sun.tools.javac.code.TypeTags
    java:java.lang.ExceptionInInitializerErrorcom.sun.tools.javac.code.TypeTags   这个可能原因是你编译器的环境使用过高。但是你的依赖 <dependency>......
  • Docker私有仓库以及Docker shell
    Docker搭建私有仓库公有云:比如百度云,dockerhub私有云:比如搭建到某个内网,docker搭建私有仓库:下载一个镜像docker默认使用的是dockerhubdocker仓库服务器就是docker注册服务......
  • Metagenome数据库构建_物种组成_丰度估计 2023.01.04
    物种组成_丰度估计***下载数据库###kraken2databasewgethttps://genome-idx.s3.amazonaws.com/kraken/k2_pluspf_8gb_20210517.tar.gztar-zxvfk2_pluspf_8gb_20210517.......
  • IDE committ规范及要求——多次提交的committ通过rebase合并
    第一步:切换到待上库分支 第二步:点击Git-->rebase  第三步:选择需要上库的分支以及rebase参数,点击REBASE:  第四步:squash多次修改成一次,全选多次修改-->点......
  • 新建git仓库
    clone代码到本地gitclonehttps://xxx.com/repo.gitmyRepo删除原.git文件,重新初始化项目目录为git目录gitinit添加文件gitadd.提交文件到本地仓库gitcom......