当前位置: 首页 > news >正文

docker和Helm Chart的基本命令和操作

一、docker基本命令和操作

1. docker login【登录】

登录 docker client,登录成功之后会显示 Login Succeeded。
docker login登陆到指定的镜像仓库,docker pull 和 docker push 操作都需要预先执行 docker login 操作;
指令:(这里的用户名、密码和镜像仓库都换成自己的)

docker login -u <username> -p <password> iregistry.baidu-int.com

举例说明:

➜  ~ docker login -u yangxiaonan01 -p Xxxxxxx123 iregistry.baidu-int.com WARNING! Using --password via the CLI is insecure. Use --password-stdin.Login Succeeded
2.docker pull【拉取】

指令:

docker pull iregistry.baidu-int.com/<namespace>/IMAGE[:TAG]

举例说明:

➜  ~ docker pull iregistry.baidu-int.com/xk-repo-test/centos-test:1.0.11.0.1: Pulling from xk-repo-test/centos-test8a29a15cefae: Pull complete Digest: sha256:9e0c275e0bcb495773b10a18e499985d782810e47b4fce076422acb4bc3da3ddStatus: Downloaded newer image for iregistry.baidu-int.com/xk-repo-test/centos-test:1.0.1iregistry.baidu-int.com/xk-repo-test/centos-test:1.0.1
3.docker save【保存】

指令:

docker save -o 景象名.tar 镜像地址

该指令会将镜像保存在本地,执行命令的目录上

4.docker build【构建】

指令:

docker build -f <dockerFile> -t iregistry.baidu-int.com/<namespace>/IMAGE[:TAG] <contextPath>

注意:

dockerFile:一个用来构建镜像的文本文件

  • namespace:命名空间。一个组织维度,包含多个镜像仓库,和chart
  • IMAGE:镜像名称
  • TAG:镜像标签
  • contextPath:指定构建镜像的上下文的路径,构建镜像的过程中,可以且只可以引用上下文中的任何文件

举例说明:

➜  ~ vi ~/Desktop/work/DockerFile/dockerfile-nginx ➜  ~ cat ~/Desktop/work/DockerFile/dockerfile-nginx 
FROM iregistry.baidu-int.com/yxn-test/nginx:latest
MAINTAINER yxn<yangxiaonan01@baidu.com>➜  ~ docker build -f ~/Desktop/work/DockerFile/dockerfile-nginx -t iregistry.baidu-int.com/yxn-test/nginx:v1.0 .➜  ~ docker images
REPOSITORY                                    TAG       IMAGE ID       CREATED         SIZE
iregistry.baidu-int.com/yxn-test/nginx        v1.0      1a6c19b45d6e   2 days ago      133MB
5.docker push【推送】

指令:

docker push iregistry.baidu-int.com//IMAGE[:TAG]

注意:

  • namespace:命名空间。一个组织维度,包含多个镜像仓库,和chart
  • IMAGE:镜像名称
  • TAG:镜像标签

举例说明:

   ➜  ~ docker push iregistry.baidu-int.com/yxn-test/centos-test:1.0.1     The push refers to repository [iregistry.baidu-int.com/yxn-test/mysql]03a007e88ba3: Pushed d605c112cfab: Pushed 74634a9cf30b: Pushed ea5fd90d1e58: Pushed cffd1f984514: Pushed 3182d4b853f0: Pushed ae477702a513: Pushed 570df12e998c: Pushed b2abc2ad4a41: Pushed e82f328cb5e6: Pushed 14be0d40572c: Pushed 02c055ef67f5: Pushed latest: digest: sha256:68b207d01891915410db3b5bc1f69963e3dc8f23813fd01e61e6d7e7e3a46680 size: 2828
6.docker tag【打标签】

指令:

docker tag SOURCE_IMAGE[:TAG] iregistry.baidu-int.com/<namespace>/IMAGE[:TAG]

注意:

  • namespace:命名空间。一个组织维度,包含多个镜像仓库,和chart
  • IMAGE:镜像名称
  • TAG:镜像标签

举例说明:

  docker tag iregistry.baidu-int.com/xk-repo-test/centos-test:1.0.1  iregistry.baidu-int.com/yxn-test/centos-test:1.0.2

二、Chart的基本命令和操作

1. helm安装与配置
参考文档:https://helm.sh/docs/intro/install/

2. 添加仓库
简介:根据iRegistry仓库的用户名、密码,在本地添加chart repo【注意:添加一次即可】

指令:
helm repo add --username --password https://iregistry.baidu-int.com/chartrepo/

注意:
namespace:命名空间。一个组织维度,包含多个镜像仓库,和chart

指令执行结果,举例说明:

➜  ~ helm repo add --username yangxiaonan01 --password Yangxiaonan01 yxn-test https://iregistry.baidu-int.com/chartrepo/yxn-test
"yxn-test" has been added to your repositories
➜  ~ helm repo list                                                                                     
NAME    	URL                                               
yxn-test	https://iregistry.baidu-int.com/chartrepo/yxn-test

3.下载 Chart
简介:从chart仓库中下载指定版本的chart到本地;

第一步:配置 helm fetch 时使用的密码,详见【Helm Chart基本操作 --> 前提】,若已经配置过,则跳过;

第二步:本地添加仓库,详见【Helm Chart基本操作 --> 添加仓库】,若已经添加过,则跳过;
指令:
helm fetch --version <Chart 版本> <本地仓库名称>/<Chart 名称>

指令执行结果,举例说明:

➜  ~ helm fetch --version 0.1.0-145583081-1609409229920 yxn-test/helm2-demo

4.上传 Chart

简介:将本地中存在的chart文件上传到iRegistry镜像仓库中;

第一步:配置helm push的密码,详见【Helm Chart基本操作 --> 前提】,若已经配置过,则跳过;

第二步:安装 helm push 插件,参考链接:helm push插件安装;

第三步:本地添加仓库,详见【Helm Chart基本操作 --> 添加仓库】,若已经添加过,则跳过;

第四步:上传chart,helm push

  • chart package:charts文件包
  • charts repo:charts仓库名称
    指令:
➜  ~ helm plugin install https://github.com/chartmuseum/helm-push.git # 第二步:安装helm push插件
Downloading and installing helm-push v0.9.0 ...
https://github.com/chartmuseum/helm-push/releases/download/v0.9.0/helm-push_0.9.0_darwin_amd64.tar.gz
Installed plugin: push    ➜  ~ helm repo add --username yangxiaonan01 --password Xxxx1234  yxn-test https://iregistry.baidu-int.com/chartrepo/yxn-test # 第三步:添加仓库
"yxn-test" has been added to your repositories➜  ~ helm repo list  # 查看仓库列表
NAME        	URL                                                   
yxn-test    	https://iregistry.baidu-int.com/chartrepo/yxn-test    ➜  ~ helm push ~/Downloads/sec-brain-web-0.0.1-162952076.tgz yxn-test  # 第四步:上传chart                                 
Pushing sec-brain-web-0.0.1-162952076.tgz to yxn-test...
Done.

5.安装 Chart
简介:将某个chart版本部署到k8s集群中;
第一步:配置 helm install 时使用的密码,详见【Helm Chart基本操作 --> 前提】,若已经配置过,则跳过;
第二步:本地添加仓库,详见【Helm Chart基本操作 --> 添加仓库】,若已经添加过,则跳过;
第三步:执行helm install 指令:
helm install --username= --password= --version <Chart 版本> <本地仓库名称>/<Chart 名称>

http://www.lryc.cn/news/419816.html

相关文章:

  • Node中的CSRF攻击和防御
  • CSS 多按钮根据半圆弧度排列
  • 【Linux】网络编程套接字Scoket:UDP网络编程
  • 基于模糊PID控制器的puma560机器人控制系统的simulink建模与仿真
  • C语言文件操作超详解
  • 表字段显示tip
  • 十二、享元模式
  • 黑马Java零基础视频教程精华部分_18_Arrays各种方法
  • RAG私域问答场景超级详细方案(第一期方案)[1]:工业级别构建私域问答(知识处理、知识召回排序、搜索问答模块)
  • 【AI在医疗领域的应用】AI在疾病诊断、个性化治疗等领域的应用
  • SpEL结合AOP示例
  • 【Linux:环境变量】
  • 8月9日笔记
  • API 签名认证:AK(Access Key 访问密钥)和 SK(Secret Key 私密密钥)
  • Redis 单机和集群环境部署教程
  • 华为hcip-big data 学习笔记《一》大数据应用开发总指导
  • 用户画像架构图
  • 37.x86游戏实战-XXX遍历怪物数组
  • go语言中map为什么不会自动初始化?
  • 大数据面试SQL(一):合并日期重叠的活动
  • stm32应用、项目、调试
  • WEB渗透-未授权访问篇
  • x86_64、AArch64、ARM32、LoongArch64、RISC-V
  • git push上不去的问题Iremote reiectedl——文件过大的问题
  • Qt Creator卡顿
  • 数据结构笔记(其五)--串
  • Python爬取高清美女图片
  • gin路由
  • 达梦数据库操作以及报错修改
  • 江科大/江协科技 STM32学习笔记P21