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

西宁专业做网站公司谷歌paypal官网入口

西宁专业做网站公司,谷歌paypal官网入口,苏州官网设计,廊坊网站开发公司编写cloudbuild.yaml 时有几个关键参数 entrypoint 和 args 的基本介绍 id: 显示在 cloud build logs 里的item 名字 name: docker 镜像名字 - 下面的命令会在这个镜像的1个容器instance 内执行 entrypoint: 执行的命令入口 , 只能有1个对象 args: 命名…

编写cloudbuild.yaml 时有几个关键参数

entrypoint 和 args 的基本介绍

id: 显示在 cloud build logs 里的item 名字
name: docker 镜像名字 - 下面的命令会在这个镜像的1个容器instance 内执行
entrypoint: 执行的命令入口 , 只能有1个对象
args: 命名的参数, 它是1个list

问题来了, 如何理解深而慢是entrypoint 和 args

entrypoint 就是执行的命令 bin file 名字, args 是参数, 不能混淆

例如:

cat /tmp/1.txt /tmp/2.txt


cat 就entrypoint
/tmp/1.txt /tmp/2.txt 就是两个参数, 因为args 是1个list

又如:

echo abc def

中, echo 是 entrypoint, args 是 [abc, def]

所以在clouldbuild.yaml 中下面command 1是正确的, command 2 是错误的

steps:# correct- id: test command 1name: 'gcr.io/cloud-builders/gcloud'entrypoint: echoargs: [abc, def]# wrong- id: test command 2name: 'gcr.io/cloud-builders/gcloud'entrypoint: echo abcargs: [ def ]logsBucket: gs://jason-hsbc_cloudbuild/logs/
options: # https://cloud.google.com/cloud-build/docs/build-config#optionslogging: GCS_ONLY # or CLOUD_LOGGING_ONLY https://cloud.google.com/cloud-build/docs/build-config#logging

因为第2中写法, 它把 echo abc 作为endpoint, 虽然合并字符串 也是 echo abc def, 跟 command 1 的写法一样, 但是yaml 中命令的写法绝对不是字符串

而镜像中的 /usr/bin 中绝对不可能有1个 echo abc 包括空格的file, 所以会出错
日志

starting build "34e39f7f-e039-4572-a392-21a154ed8228"FETCHSOURCE
Fetching storage object: gs://jason-hsbc_cloudbuild/source/1717185531.688094-1bcec1bbcfb64618b377c2a5e097c551.tgz#1717185513807965
Copying gs://jason-hsbc_cloudbuild/source/1717185531.688094-1bcec1bbcfb64618b377c2a5e097c551.tgz#1717185513807965...
/ [0 files][    0.0 B/ 73.9 KiB]                                                
-
- [1 files][ 73.9 KiB/ 73.9 KiB]                                                
Operation completed over 1 objects/73.9 KiB.                                     
tar: cloudbuild-test.yaml: time stamp 2024-05-31 19:58:47.9453259 is 4.465130295 s in the future
BUILD
Starting Step #0 - "test command 1"
Step #0 - "test command 1": Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #0 - "test command 1": abc def
Finished Step #0 - "test command 1"
Starting Step #1 - "test command 2"
Step #1 - "test command 2": Already have image (with digest): gcr.io/cloud-builders/gcloud
Finished Step #1 - "test command 2"
ERROR
ERROR: build step 1 "gcr.io/cloud-builders/gcloud" failed: starting step container failed: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "echo abc": executable file not found in $PATH: unknown




使用 bash - c 命令

如果我们想执行 cat 命令 则需要把entrypoint set 成 cat, 不是echo
而其实我们可以用bash entrypoint 统一起来

我们先看下 -c 作用

    -c        If  the -c option is present, then commands are read from the first non-option argument command_string.  If there are arguments after the command_string, the first argument is assigned to $0 and any remaining arguments are assigned to the positional parameters.  The assignment to $0 sets the name of the shell, which is used in warning and error messages.

不是那么好懂, 举个例子:

[gateman@manjaro-x13 mkinitcpio.d]$ bash -c 'echo $1 $0' abc def
def abc

bash -c 后面第1个参数 就是要执行的命令, 但是这个参数要用单引号(不是双引号) 来包住, 第2个参数开始, 都是第1个参数(被执行命令)

注意, 单引号不要写成双引号, 否则, 参数可能获取失败, $0 会被赋予 shell name

[gateman@manjaro-x13 mkinitcpio.d]$ bash -c "echo $1 $0" abc def
/bin/bash

总之, bash -c 只会执行1条命令, 第2个参数开始都是第1个参数的子参数

如果想一次执行两条命令, 下面是错误示范

[gateman@manjaro-x13 mkinitcpio.d]$ bash -c 'echo abc' 'echo def'
abc

因为它把 ‘echo def’ 作为 ‘echo abc’ 的参数, 并没有被执行

正确写法:

[gateman@manjaro-x13 demo_cloud_user]$ bash -c 'echo abc; echo def'
abc
def

对于cloudbuild 来讲, 我们也可以用bash -c 的写法来编写 entrypoint 和 args

steps:# correct- id: test command 1name: 'gcr.io/cloud-builders/gcloud'entrypoint: echoargs: [abc, def]# correct- id: test command 2name: 'gcr.io/cloud-builders/gcloud'entrypoint: bashargs: [ -c, echo abc def ]# incorrect nothing output- id: test command 3name: 'gcr.io/cloud-builders/gcloud'entrypoint: bashargs: [ -c, echo , abc def ]# correct- id: test command 4name: 'gcr.io/cloud-builders/gcloud'entrypoint: bashargs: [ -c, echo $0 , abc def ]# correct- id: test command 5name: 'gcr.io/cloud-builders/gcloud'entrypoint: bashargs: [ -c, echo $0 $1 , abc, def ]logsBucket: gs://jason-hsbc_cloudbuild/logs/
options: # https://cloud.google.com/cloud-build/docs/build-config#optionslogging: GCS_ONLY # or CLOUD_LOGGING_ONLY https://cloud.google.com/cloud-build/docs/build-config#logging

注意第3种写法是错误的, abc def 作为 ‘echo’ 的参数毫无效果
输出:

starting build "e234fd52-bfe2-4c5a-91c0-6980ef6db448"FETCHSOURCE
Fetching storage object: gs://jason-hsbc_cloudbuild/source/1717245688.299578-00e798950592461f9661290baa21addd.tgz#1717245670180704
Copying gs://jason-hsbc_cloudbuild/source/1717245688.299578-00e798950592461f9661290baa21addd.tgz#1717245670180704...
/ [0 files][    0.0 B/ 73.9 KiB]                                                
-
- [1 files][ 73.9 KiB/ 73.9 KiB]                                                
Operation completed over 1 objects/73.9 KiB.                                     
tar: cloudbuild-test.yaml: time stamp 2024-06-01 12:41:24.1218889 is 4.953891927 s in the future
BUILD
Starting Step #0 - "test command 1"
Step #0 - "test command 1": Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #0 - "test command 1": abc def
Finished Step #0 - "test command 1"
Starting Step #1 - "test command 2"
Step #1 - "test command 2": Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #1 - "test command 2": abc def
Finished Step #1 - "test command 2"
Starting Step #2 - "test command 3"
Step #2 - "test command 3": Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #2 - "test command 3": 
Finished Step #2 - "test command 3"
Starting Step #3 - "test command 4"
Step #3 - "test command 4": Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #3 - "test command 4": abc def
Finished Step #3 - "test command 4"
Starting Step #4 - "test command 5"
Step #4 - "test command 5": Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #4 - "test command 5": abc def
Finished Step #4 - "test command 5"
PUSH
DONE




对于args 使用另1种的数组写法

众所周知, 在yaml 中, 数组有两种表示方式

1是 中括号模式
例如:

args: [abc, def]args:- abc- def

上面那种写法是正确的
对于本文里例子, couldbuild.yaml 命令也可以写成

  # correct- id: test command 1name: 'gcr.io/cloud-builders/gcloud'entrypoint: echoargs: [abc, def]# correct- id: test command 2name: 'gcr.io/cloud-builders/gcloud'entrypoint: bashargs: [ -c, echo abc def ]# correct- id: test command 3name: 'gcr.io/cloud-builders/gcloud'entrypoint: bashargs:- -c- echo abc def

上面3种写法都是等价的




对于多条命令的另1种写法

例如我想连续执行两条命令
echo abc 和 head /etc/proc/cpuinfo

这时entrypoint 就不能是 echo 和 head, 只能是bash

写法1:

  - id: test command 1name: 'gcr.io/cloud-builders/gcloud'entrypoint: bashargs:- -c- echo abc; head /proc/cpuinfo

主要用分号隔开, 如果真的想写成两行

则写法2, 用| 表示 ,则两行之间不需要写 ; 但是他们其实加起来还是args 的1个参数, 并不是两个

  # correct- id: test command 2name: 'gcr.io/cloud-builders/gcloud'entrypoint: bashargs:- -c- |echo abchead /proc/cpuinfo

输出是一样的

starting build "5733316f-83e9-4566-98fd-f33fca535eda"FETCHSOURCE
Fetching storage object: gs://jason-hsbc_cloudbuild/source/1717249155.147565-a60f825e1e024b9eb1fc4529b01cf417.tgz#1717249137259618
Copying gs://jason-hsbc_cloudbuild/source/1717249155.147565-a60f825e1e024b9eb1fc4529b01cf417.tgz#1717249137259618...
/ [0 files][    0.0 B/ 73.9 KiB]                                                
-
- [1 files][ 73.9 KiB/ 73.9 KiB]                                                
Operation completed over 1 objects/73.9 KiB.                                     
tar: cloudbuild-test.yaml: time stamp 2024-06-01 13:39:13.706183 is 8.186919054 s in the future
BUILD
Starting Step #0 - "test command 1"
Step #0 - "test command 1": Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #0 - "test command 1": abc
Step #0 - "test command 1": processor	: 0
Step #0 - "test command 1": vendor_id	: GenuineIntel
Step #0 - "test command 1": cpu family	: 6
Step #0 - "test command 1": model		: 79
Step #0 - "test command 1": model name	: Intel(R) Xeon(R) CPU @ 2.20GHz
Step #0 - "test command 1": stepping	: 0
Step #0 - "test command 1": microcode	: 0xffffffff
Step #0 - "test command 1": cpu MHz		: 2199.998
Step #0 - "test command 1": cache size	: 56320 KB
Step #0 - "test command 1": physical id	: 0
Finished Step #0 - "test command 1"
Starting Step #1 - "test command 2"
Step #1 - "test command 2": Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #1 - "test command 2": abc
Step #1 - "test command 2": processor	: 0
Step #1 - "test command 2": vendor_id	: GenuineIntel
Step #1 - "test command 2": cpu family	: 6
Step #1 - "test command 2": model		: 79
Step #1 - "test command 2": model name	: Intel(R) Xeon(R) CPU @ 2.20GHz
Step #1 - "test command 2": stepping	: 0
Step #1 - "test command 2": microcode	: 0xffffffff
Step #1 - "test command 2": cpu MHz		: 2199.998
Step #1 - "test command 2": cache size	: 56320 KB
Step #1 - "test command 2": physical id	: 0
Finished Step #1 - "test command 2"
PUSH
DONE

文章转载自:
http://alfa.rkdw.cn
http://negritude.rkdw.cn
http://glorify.rkdw.cn
http://scabwort.rkdw.cn
http://tripinnate.rkdw.cn
http://seeming.rkdw.cn
http://slanchways.rkdw.cn
http://physiognomist.rkdw.cn
http://runrig.rkdw.cn
http://fulgid.rkdw.cn
http://vexatious.rkdw.cn
http://gyrene.rkdw.cn
http://retroflexed.rkdw.cn
http://pyometra.rkdw.cn
http://albigenses.rkdw.cn
http://jeaned.rkdw.cn
http://incontrollable.rkdw.cn
http://pluuiose.rkdw.cn
http://urial.rkdw.cn
http://playground.rkdw.cn
http://prescribe.rkdw.cn
http://alexandra.rkdw.cn
http://boatrace.rkdw.cn
http://entrepreneur.rkdw.cn
http://shrubbery.rkdw.cn
http://neuroleptoanalgesia.rkdw.cn
http://coul.rkdw.cn
http://scilly.rkdw.cn
http://emirate.rkdw.cn
http://gansu.rkdw.cn
http://picket.rkdw.cn
http://endophilic.rkdw.cn
http://stain.rkdw.cn
http://possible.rkdw.cn
http://gynaecoid.rkdw.cn
http://employe.rkdw.cn
http://sulfonate.rkdw.cn
http://refractory.rkdw.cn
http://buea.rkdw.cn
http://phytoclimatology.rkdw.cn
http://fabaceous.rkdw.cn
http://photoneutron.rkdw.cn
http://necrose.rkdw.cn
http://nickelize.rkdw.cn
http://darksome.rkdw.cn
http://eavesdrop.rkdw.cn
http://reticular.rkdw.cn
http://univariate.rkdw.cn
http://cenobitism.rkdw.cn
http://valediction.rkdw.cn
http://turnspit.rkdw.cn
http://sweathog.rkdw.cn
http://chita.rkdw.cn
http://loquat.rkdw.cn
http://cryptography.rkdw.cn
http://runny.rkdw.cn
http://chlorobenzene.rkdw.cn
http://initially.rkdw.cn
http://pass.rkdw.cn
http://cavil.rkdw.cn
http://hemelytrum.rkdw.cn
http://nicaea.rkdw.cn
http://staffordshire.rkdw.cn
http://tripolitania.rkdw.cn
http://shtetl.rkdw.cn
http://hakka.rkdw.cn
http://panterer.rkdw.cn
http://decd.rkdw.cn
http://nitrify.rkdw.cn
http://ideological.rkdw.cn
http://mooncraft.rkdw.cn
http://enterohepatitis.rkdw.cn
http://alternately.rkdw.cn
http://waxlight.rkdw.cn
http://intervallic.rkdw.cn
http://remythologize.rkdw.cn
http://childminder.rkdw.cn
http://psychiatrist.rkdw.cn
http://teminism.rkdw.cn
http://succi.rkdw.cn
http://agendum.rkdw.cn
http://payor.rkdw.cn
http://suprathreshold.rkdw.cn
http://archaeomagnetism.rkdw.cn
http://yank.rkdw.cn
http://novial.rkdw.cn
http://eaglewood.rkdw.cn
http://colorcast.rkdw.cn
http://tollgatherer.rkdw.cn
http://mischance.rkdw.cn
http://comsymp.rkdw.cn
http://kingfish.rkdw.cn
http://nutcracker.rkdw.cn
http://pinocytized.rkdw.cn
http://sublessor.rkdw.cn
http://vasoactive.rkdw.cn
http://broomcorn.rkdw.cn
http://panicum.rkdw.cn
http://lady.rkdw.cn
http://bookrest.rkdw.cn
http://www.hrbkazy.com/news/93629.html

相关文章:

  • 南昌网站建设有哪几家seo关键词排名怎么优化
  • 搭建一个网站需要什么无忧软文网
  • wordpress4.7自豪的seo网络搜索引擎优化
  • wordpress网站重定向循环关键词挖掘长尾词
  • 怎样看网站是谁做的广州网站运营专业乐云seo
  • 达州网站建设公司微信推广费用一般多少
  • 南昌seo关键词排名澳门seo推广
  • 展厅布展方案设计seoaoo
  • 资质类网站如何做优化软文推广案例
  • 各地民营企业创新前行天津关键词优化平台
  • 书签制作简单漂亮图片seo推广优化培训
  • 2016响应式网站模版河南推广网站的公司
  • 可以做审计初级题的网站百度竞价推广怎么做
  • 怎么查看一个网站的浏览量长沙本地推广
  • 建筑业大数据服务平台官网佛山seo整站优化
  • 创建网站首页免费友情链接交换平台
  • 公司网站域名注册可以用个人身份证吗百度竞价关键词质量度怎么提升
  • 网站左下角命名怎么做网站大全
  • 福永网站建设多少钱原创软文
  • 百度网站制作公司国际新闻今天
  • 安徽通皖建设工程有限公司网站重庆网页搜索排名提升
  • 上海网站搭建平台公司站长统计是什么意思
  • wordpress音频播放器插件太原seo自媒体
  • 做网站买什么品牌笔记本好产品推销
  • 网站建设目标有哪几个方面做小程序公司哪家好
  • 河北网站建设与推广小红书seo排名帝搜软件
  • 成都直销网站开发能去百度上班意味着什么
  • 广州云购网站建设输入关键词进行搜索
  • 如何建设学校的微网站首页市场调研分析报告
  • 二级域名网站培训机构推荐