Alright.
We have just removed the all containers that were stopped before and if I type now, Docker PS dash
A, you'll see empty output and if you have not cleaned your containers, please watch the previous
lecture.
In this lecture, let's create a container based on Python image.
And for that let's first pull Python image from Docker Hub.
Docker pull Python.
And I don't specify any tag.
It means that latest version of Python image will be pulled.
Notice that now we are downloading basically multiple file system layers and they are relatively large
in comparison.
For example to Alpine or ubuntu image.
Let's wait a bit.
Actually from this output you see that we have actually pulled compressed layers and afterwards locally
we extract contents from that compressed layers.
Wonderful image was pulled and here is its Sha 256 hash and you see that we have downloaded python latest
image latest is its tag.
Great.
Let's now verify list of images Docker images and you'll see here Python on the list and its size is
around one gigabyte.
It is really, really huge in comparison to other images like nginx, alpine or ubuntu.
Wonderful.
Let's now try to create container based on this python image and let's simply use docker run command
with name of the image python.
Let's clear terminal docker run python.
And as before, we see that container was basically created under the hood, but it was immediately
terminated.
Let's list here containers, Docker, PS And you see no containers currently running, but there is
a single container here in the history and it was exited 14 seconds ago.
And you see here command that was executed.
It was Python three, but we have not connected to standard in of this process.
This process was exited therefore and afterwards container was terminated by Docker because there were
no processes running.
Again, situation is the same as we have seen, for example with Alpine or Ubuntu containers.
If you don't connect to standard input of specific process, process exits automatically and Docker
stops such container.
Great.
Let me now clear terminal and run this container with options.
Dash i and dash t docker run dash it.
I can combine those two options and here will be python like so.
And now you see that we have actually opened interactive session with Python.
Actually the same happens when Python is installed locally on your computer and when you enter Python
three or Python command.
We are now inside of the interactive shell with Python.
Let's now, for example, enter help here.
Actually, in order to get interactive help, I need to add parentheses here like so and you'll see
message.
Welcome to Python 3.8 and here you see that you are able to explore help for different modules, keywords
or symbols like you see here.
And for example, we are able to get list of Python modules by entering modules.
And afterwards you are able to get help about any of those modules.
And let's, for example, get help about the Lib module and for that simply type name of corresponding
module here, zlib like so, and you'll get module reference here and you may read about this module,
what it does and how it is used.
Actually great.
That's how you able to get help inside of this interactive session.
And if you want to exit from here, you could simply press Q and press enter.
And afterwards here you are able to execute any Python commands.
For example, let's type three plus seven, I get ten, let's print hello from Python like so and I
get Hello from Python here.
That's how you able to interact with Python interpreter okay.
Also notice that this container is still up and running because we are now connected to standard in
and standard output of specific process, namely Python three process.
And if I open new tab and list containers here, Docker PS you see that the Python image was used for
creation of this container with container ID, this one and the random name.
This one was assigned to this container and here you see command that was automatically executed.
Python three.
All right, Let's now go back to this step and let's exit from this interactive session.
And for that you could type exit with parentheses like so.
Process was terminated and container was stopped as well.
Let's verify that.
Docker PS And yes, there are no running containers, but this container is listed here.
If I add a option, all great.
That's how we were able to create the python container and run some code inside of that container.
But of course, in practice during development usually you need to have a python container in order
to execute your python applications.
And next, let me demonstrate you how you are able to run your specific project located on your local
computer using Python container.
Let's do that next.
Bye bye.