有人能解释一下docker-compose的以下行为(并提供解决方法)吗?
给出以下文件:
Dockerfile
FROM alpine:3.8
COPY ./entrypoint.sh /entrypoint.sh
ENTRYPOINT [ "/entrypoint.sh" ]
entrypoint.sh
#!/bin/sh
until [ ! -z "$PLOP" ]; do
echo -n 'enter value here: '
read PLOP
done
echo "Good ... PLOP is $PLOP"
exit 1
docker-compose.yml
version: '3.7'
services:
plop:
tty: true
stdin_open: true
image: webofmars/plop:latest
输出将会是以下内容:
1) ./entrypoint.sh
docker-stdin> ./entrypoint.sh
enter value here:
CASE1
Good ... PLOP is CASE1
看起来不错
2) docker-stdin> docker run -it webofmars/plop
enter value here: CASE2
Good ... PLOP is CASE2
看起来不错
3) docker-stdin> docker-compose run plop
enter value here: CASE3
Good ... PLOP is CASE3
似乎OK
4) docker-stdin> docker-compose up
Recreating docker-stdin_plop_1 ... done
Attaching to docker-stdin_plop_1 (last forever)
这似乎对我的使用情况来说相当奇怪和不合适
我有遗漏什么吗?