# \[Solved\] Docker exec to send command to running process stdin

**URL:** <https://forums.docker.com/t/solved-docker-exec-to-send-command-to-running-process-stdin/19517>\
**Category:** General\
**Created:** [August 1, 2016, 6:20pm UTC](https://forums.docker.com/t/solved-docker-exec-to-send-command-to-running-process-stdin/19517 "2016-08-01T18:20:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vnxdev](https://avatars.discourse-cdn.com/v4/letter/v/cc9497/32.png) [@vnxdev](https://forums.docker.com/u/vnxdev)\
**Post date:** [August 1, 2016, 6:20pm UTC](https://forums.docker.com/t/solved-docker-exec-to-send-command-to-running-process-stdin/19517/1 "2016-08-01T18:20:02Z")

</div>

Hi,

I started container with java process and -d switch (detached). Now I want to send command to that running java process (as if I would run this container without -d interactively and print command manually). If I use

docker exec -it my\_container set a=1

where “set a=1” is the command, than I get error:

rpc error: code = 2 desc = oci runtime error: exec failed: exec: “set”: executable file not found in $PATH

So I suppose that docker is trying to run this command not in the process in foreground but on the container os command line (bash?). So the question is how can I send commands to the process in the foreground inside running container?

---

<div class="post-metadata">

**Author:** ![vnxdev](https://avatars.discourse-cdn.com/v4/letter/v/cc9497/32.png) [@vnxdev](https://forums.docker.com/u/vnxdev)\
**Post date:** [August 1, 2016, 8:25pm UTC](https://forums.docker.com/t/solved-docker-exec-to-send-command-to-running-process-stdin/19517/2 "2016-08-01T20:25:54Z")

</div>

The solution I came up with is to run docker container inside linux screen. I start container in detached screen session like this:

`screen -AmdS my_app_screen docker run -it --name my-app myimage`

and then I use this bash script to send “set a=1” command to the docker container stdin:

```
screen -p 0 -S my_app_screen -X eval "stuff 'set a=1'\015"
sleep 1;

```

And btw, Docker Remote API could be used to achieve this too, but it’s more suitable to use within you web apps.
