phil swenson
phil swenson

Reputation: 8894

how to get docker container to read from stdin?

I have a script that I want to use to use Sigil (based on Go's template engine) to populate template files

I'm using a dockerized sigil for this via:

docker run -v ${TEMPLATE_DIR}:/tmp/sigil mikegrass/gliderlabs_sigil-docker/sigil -f prometheus-configmap.yaml -p API_SERVER=$api_server_url > $TEMP_FILE

This seems a bit clunky with having to map a volume, so I'd rather use STDIN to pass in the file....

So what I'd like is

cat ./prometheus-configmap.yaml | docker run mikegrass/gliderlabs_sigil-docker -p API_SERVER=$api_server_url > $TEMP_FILE

Unfortunately this doesn't work, I get no output.

Googling around I see possible solutions but haven't gotten any to work...

Upvotes: 28

Views: 20995

Answers (2)

rouble
rouble

Reputation: 18191

Without cat:

docker run -i mikegrass/gliderlabs_sigil-docker -p API_SERVER=$api_server_url < ./prometheus-configmap.yaml

Upvotes: 4

Andy Shinn
Andy Shinn

Reputation: 28493

You need to run the container in interactive mode with --interactive or -i:

cat ./prometheus-configmap.yaml | docker run -i mikegrass/gliderlabs_sigil-docker -p API_SERVER=$api_server_url > $TEMP_FILE

Upvotes: 40

Related Questions