Alexander Mills
Alexander Mills

Reputation: 100000

Send stdin to bash process in docker container

Say I have:

ENTRYPOINT /bin/bash

and I start the container:

docker run -d -it foo

is there a way to write to the stdin of the bash process in the container?

Upvotes: 0

Views: 947

Answers (1)

BMitch
BMitch

Reputation: 263617

You can either avoid detaching from the container when you create it, or you can attach to an already running container. In each case, an EOF on the input that you send in will be an EOF to bash which will cause the container to exit.

Remove the -d to avoid detaching:

docker run -it foo

Attach to a running container:

docker run -d -it --name bar foo
docker attach -it bar

Upvotes: 1

Related Questions