How to create a container that waits for user input when using docker attach

hi all, i’ve been to create 2 containers , 1 gets user input and save it to file , second watch the folder the file exists in , and copies it to another location . now the scripts run fine , when running them manually , but under automation …not such much .

here is the problem:

2 containers running, when i try to attach to each one of them , i do not see the right output , meaning , on the first container that i should see the pharse “enter user input” , i see it running infinitely without waiting for the user to enter input . on the second container , i do not see the inotifywait command running , just prompt…

main container output:

please enter input:

please enter input:

please enter input:

and it goes on .

the second container : (which is nothing…)

here by is the code:
entrypoint.sh

x = 1
while x=1 ; do
echo “please enter input:”
read userinput
echo $userinput > /home/igalc/myvol/testfirst$num.txt
done

watchme.sh

x=1
while x=1
do
echo "watching..."
inotifywait -q -m -e create /home/igalc/myvol |
        while read file_path file_event file_name; do
                echo ${file_path}${file_name} event: ${file_event}
                echo "Copying to AWS S3 Bucket"
                aws s3 cp ${file_path}/${file_name} s3://exodigos3bucket/${file_name}.txt

        done
done


each dockerfile ends with this entrypoint

Dockerfile.Primary

FROM ubuntu:bionic-20220401
RUN mkdir testme
COPY /Primary /testme
RUN chmod +x /testme/entrypoint.sh 
ENTRYPOINT [ "/testme/entrypoint.sh" ]

Dockerfile.Secondary

FROM ubuntu:bionic-20220401
RUN apt-get update -y && apt-get install inotify-tools unzip curl -y && mkdir watchme
COPY /Secondary /watchme
RUN chmod +x /watchme/watchme.sh && chmod +X /watchme/installawscli.sh
RUN /watchme/installawscli.sh
ENTRYPOINT [ "/watchme/watchme.sh"]

what i need to do , is get one container the primary to output user input prompt,

and the DockerSecondary to watch the result.

and as i said , if run the command manually via docker exec -it [container_name] /bin/bash , it runs perfectly