Write to stdin of running docker container

Say I run a docker container as a daemon:

docker run -d foo

is there a way to write to the stdin of that container? Something like:

docker exec -i foo echo 'hi'

last time I checked the -i and -d flags were mutually exclusive when used with the docker run command.

Source: StackOverflow