尝试通过运行一个简单的命令与正在运行的 docker 容器进行通信curl:
curl -v -s -X POST http://localhost:4873/_session -d \'name=some\&password=thing\'
Run Code Online (Sandbox Code Playgroud)
在任何 shell(登录/交互式)中都可以正常工作,但在脚本中执行时却惨遭失败:
temp=$(curl -v -s -X POST http://localhost:4873/_session -d \'name=some\&password=thing\')
echo $temp
Run Code Online (Sandbox Code Playgroud)
错误输出提示连接重置:
* Trying 127.0.0.1:4873...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 4873 (#0)
> POST /_session HTTP/1.1
> Host: localhost:4873
> User-Agent: curl/7.68.0
> Accept: */*
> Content-Length: 29
> Content-Type: application/x-www-form-urlencoded
>
} [29 bytes data]
* upload completely sent off: 29 out of 29 bytes
* Recv failure: Connection reset by …Run Code Online (Sandbox Code Playgroud)