Saturday 9 May 2020

Docker : Run Python Interpreter

Execute below command to open python interpreter.
docker run -it --rm python:3

-it: Run the container in interactive mode.
--rm: Remove the container after its execution.

Since I am not specified the command to run, it runs python interpreter by default.
$docker run -it --rm python:3
Python 3.8.2 (default, Apr 23 2020, 14:22:33) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

Now, you can execute any python valid commands in the interpreter.
>>> print("Hello World")
Hello World
>>> 
>>> 10 + 11
21
>>>

Execute the command exit() to come out of interpreter prompt.
>>> exit()
$


Previous                                                    Next                                                    Home

No comments:

Post a Comment