今天使用curl指令构造一个docker api访问,一直得不到预期的结果。调试了半天,发现是网址没加引号。

token=$(curl -v -XGET -H 'Authorization:Basic ××××' https://auth.docker.io/token?account=torresowen&scope=repository%3Alibrary%2Fnginx%3Apull&service=registry.docker.io)> /dev/null 2>&1

由于网址跟了一串参数,导致curl指令应该是参数没读全。

应该将整个网址加上单引号,这是一个shell脚本中易犯的错误,记之

token=$(curl -v -XGET -H 'Authorization:Basic ×××××' 'https://auth.docker.io/token?account=torresowen&scope=repository%3Alibrary%2Fnginx%3Apull&service=registry.docker.io')> /dev/null 2>&1

 

相关文章:

  • 2021-11-16
  • 2021-11-10
猜你喜欢
  • 2021-12-06
  • 2022-01-26
  • 2023-04-03
  • 2021-09-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案