Docker attach with command

i do docker run -dit -w /project --name test espressif/idf
and then
docker attach test
and idf.py build
Can i do something like:
echo "idf.py build" | docker attach test?
I dont want to use docker exec test idf.py build, as espressif/idf run a long entrypoint script that i want to avoid re-running in every new docker exec terminal…

Is there a reason why you just dont build the application in the image?
so you dont have to run it everytime when you create a new instance?

i have a script running in the host, and i dont want to go inside container’s terminal.
Let’s say this is myscript.bat (running in windows cmd), if i do docker attach i have this problem:

# myscript.bat
echo "show stuff in host's terminal"
docker run -dit -w /project --name test espressif/idf
docker attach test
# now my script will not run idf.py build as a new terminal will open
root@CONTAINER:/project#

i was thinking something like:

# myscript.bat
echo "show stuff in host's terminal"
docker run -dit -w /project --name test espressif/idf
# script just continues
echo "idf.py build" | docker attach test
# do other stuff with the same script