Why won't my docker-entrypoint.sh execute?

前端 未结 11 1205
清歌不尽
清歌不尽 2021-01-31 08:02

My ENTRYPOINT script doesn\'t execute and throws standard_init_linux.go:175: exec user process caused \"no such file or directory\". Why so?

<
11条回答
  •  滥情空心
    2021-01-31 08:20

    Sorry for hacking -- this is not a response to the question, but a description of a different problem and it's solution that has the same symptoms.

    I had

    ENTRYPOINT ["/usr/bin/curl", "-X", "POST", "http://myservice:8000", \
                  "-H", "Content-Type: application/json", \
                  "-d", '{"id": "test"}' \
    ]
    

    I was getting the error:

    /bin/bash: [/usr/bin/curl,: No such file or directory
    

    It turns out it's the single quotes that messed it up. Docker documentation has a note:

    The exec form is parsed as a JSON array, which means that you must use double-quotes (“) around words not single-quotes (‘). Blockquote

    Solution -- use double quotes instead of single and escape nested double quotes:

    ENTRYPOINT ["/usr/bin/curl", "-X", "POST", "http://myservice:8000", \
                  "-H", "Content-Type: application/json", \
                  "-d", "{\"id\": \"test\"}" \
    ]
    

提交回复
热议问题