小编web*_*ars的帖子

docker-stose和stdin上的用户输入

有人可以解释(并可能给出解决方法)以下docker-compose的行为吗?

给出以下文件:

Dockerfile

FROM alpine:3.8

COPY ./entrypoint.sh /entrypoint.sh

ENTRYPOINT [ "/entrypoint.sh" ]
Run Code Online (Sandbox Code Playgroud)

entrypoint.sh

#!/bin/sh

until [ ! -z "$PLOP" ]; do
    echo -n 'enter value here: '
    read PLOP
done

echo "Good ... PLOP is $PLOP"

exit 1
Run Code Online (Sandbox Code Playgroud)

泊坞窗,compose.yml

version: '3.7'

services:
  plop:
    tty: true
    stdin_open: true
    image: webofmars/plop:latest
Run Code Online (Sandbox Code Playgroud)

输出将如下:

1) ./entrypoint.sh

docker-stdin> ./entrypoint.sh
enter value here:
CASE1
Good ... PLOP is CASE1
Run Code Online (Sandbox Code Playgroud)

这似乎OK

2) docker-stdin> docker run -it webofmars/plop

enter value here: CASE2
Good ... PLOP is CASE2 …
Run Code Online (Sandbox Code Playgroud)

linux stdin docker docker-compose

5
推荐指数
1
解决办法
2385
查看次数

标签 统计

docker ×1

docker-compose ×1

linux ×1

stdin ×1