/greet-prompter

A simple py program used to build to a docker image, demonstrating the use case of `-it` flag

Primary LanguageDockerfile

greet-prompter

A simple py program used to build to a docker image, demonstrating the use case of -it flag.

Build the image

Clone the repo, inside the greet-prompter folder, run below command to build the image. docker build . -t prompter note that prompter is a image_name you can specify any name

image

Check the image if it's build, you can use below command. docker images image

Run the container out of the image

docker run prompter the above command will simply print the printf statement else and EOF file error. image

The error you're seeing is because the Docker container is running in a non-interactive mode, which means it can't accept input from the user. The input() function in Python is trying to read from standard input (stdin), but since there's no input available in a non-interactive Docker container, it raises an EOFError.

To make the program work, run the docker container in interactive mode and map the docker container terminal to machine terminal. docker run -it propmter image

-i is option used with docker run command to interact with running container -t option is used to map the running container's terminal to the machine's terminal the docker is hosted on.

Voila!