When containers are run with the interactive option, you can connect to the container and enter commands as if you are on the terminal:
$ docker run -itd --name busybox busybox
dcaecf3335f9142e8c70a2ae05a386395b49d610be345b3a12d2961fccab1478
$ docker attach busybox
/ # echo hello world
hello world
The attach option also allows multiple connections to view the same container and see what each is typing.
Lastly, while connected to a container with the tty option (-t), you can type Control–P Control–Q to detach from that container and leave it running in the background. You can then attach to that container again in the future.