2

I tried to build docker image via docker api with passing buildargs parameter

My try:

curl -X POST -H "Content-Type:application/tar" —unix-socket /var/run/docker.sock —data-binary "@Dockerfile.tar.gz" 'http://localhost/build?buildargs={"TIMESTAMP":"time"}'

But bad response:

{"message":"error reading build args: invalid character ':' after top-level value"}

If I remove the buildargs parameter, it works fine.

koo
  • 21
  • 2
  • 1
    I'm sorry. I solved the problem after reading the [docker api](https://docs.docker.com/engine/api/v1.40/#operation/ImageBuild). There is important sentence mentioned in the `buildars` query parameters: ```Note that {"FOO":"bar"} should be URI component encoded.``` So I found [json-url encoder](https://onlinejsontools.com/url-encode-json) – koo May 15 '21 at 08:29
  • 1
    Very nice. You can put your answer as the answer and accept it. If someone gets the same question in the future, it will be easy for that person to see the answer. – Eranga Heshan May 15 '21 at 08:36

0 Answers0