壳牌Zenzen Yomenai
当Docker-compose无法正常工作时,我以为"我暂时应该阅读docker-entrypoint.sh",但我根本看不懂。不知何故。
https://github.com/docker-library/wordpress/tree/master/php7.4/cli
docker-entrypoint.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #!/bin/sh set -euo pipefail # first arg is `-f` or `--some-option` if [ "${1#-}" != "$1" ]; then set -- wp "$@" fi # if our command is a valid wp-cli subcommand, let's invoke it through wp-cli instead # (this allows for "docker run wordpress:cli help", etc) if wp --path=/dev/null help "$1" > /dev/null 2>&1; then set -- wp "$@" fi exec "$@" |
记下您不了解的内容。
1 | set -euo pipefail |
似乎已通过set设置了各种shell选项。
[参考] https://qiita.com/m-yamashita/items/889c116b92dc0bf4ea7d
如果发生错误,则e选项被中断
u选项导致未定义的变量为错误
o选项与pipefail结合使用,当管道左侧的命令消失时,它将停止。
https://qiita.com/progrhyme/items/6e522d83de3c94aadec9
1 2 3 | if [ "${1#-}" != "$1" ]; then set -- wp "$@" fi |
我一点都不理解,所以当我实际移动它时,发现了以下内容。
由于它是
,因此if语句的含义是"如果有连字符"。我不明白
1 | set -- wp "$@" |
我一点都不明白。
[参考] https://yash.osdn.jp/doc/ja/_set.html
如果
Set命令具有一个操作数,或者如果有两个连字符(-,请参见命令参数语法)将选项与操作数分开,则当前的位置参数为,它将被删除,并且每个给定的操作数都将变为一个新的位置参数。如果给定两个连字符,并且没有操作数,则没有位置参数。
盯着它大约5分钟后,我终于明白了这句话。
当执行
即
我了解我假设我想给
wp命令本身提供选项,而其他人通常会在Dockerfile中接收CMD命令。
即使只是一个故事,也要花大量的时间来理解,因此我将其记录下来。