All right.
We have just successfully pulled the python imager.
It is around 1 gigabyte in size.
And afterwards we hope read that the python container and inside of the interactive session with Python
interpreter we executed some Python commands.
Now it's a good time to create the very small tiny python program and run it inside of the Python container
and let us simply print Hello from Python container to the terminal.
Very simple application let's create the new folder inside of the container folder.
Let me clear terminal here and let's do the visual studio code.
Let's close in this similar file.
We don't need it anymore.
Collapse and Gen X do folder.
We don't need it anymore as well.
And here let's create new folder by clicking on this icon and please make sure that you will create
a new folder near and Gen X folders and let's type here by then name for new folder and inside of this
folder list create new file.
Please select this folder with your mouse and create your file like so.
And the new file name will be simply Hello World NPI.
And next Let's type here one line.
Let's install also extension that is recommended for this file type.
It will be installed automatically by the US Code.
And meanwhile Wild is installing the let's hide this left pane and type here one single line of code
print.
And here will be a hello from the Python container because we will run this code inside of the Python
container.
Let's save the file.
Come on s let me basically close those pop ups and the next.
Let's try it to execute this file.
Hello role would be using Python interpreter inside of the Python container.
Let's go to terminal and the let's see deed to Python folder.
I am currently in containers folder city to buy it on and if I list files here I will see only one file
Hello rolled by.
Now let's create new Python container and let's try it or run this file there.
Let's put it in the following way.
Let me clear.
Terminal.
Let's use Docker run command.
That's 18.
And next comes name of the image by them.
And now somehow we need to tell Python which file it must execute and this file is located on our computer
and it is located basically in this folder where we are currently running docker container.
But how we're able to tell container which file it should execute answer was very simple.
Often name of the image here.
We could specify a command custom command that will be executed instead of the built in default command
request that the default command for this container is Python 3.
And one container is started without any additional options like.
So as you see now on the screen then Python 3 process will be started.
But instead we want to execute Hello rolled by a file using by the three interpreter.
And for that we could simply type here comment that we want to execute after Image Name Python 3.
And here we'll be the name of the file.
Hello.
This rolled not by Let's not press enter and see what will happen.
Enter and I see error Python 3 can't open the file Hello rolled.
Goodbye.
No such file or directory.
Now please stop this video and try to find out the reason why we get this error.
Please note that you already have knowledge how to fix this problem just try to think about that a bit
please post this video and fix this error
let's do that together.
Answer is very simple.
This command Python container tries to execute inside of the container.
And it looks for Hello rolled by a file inside of the container.
But now this file is located locally on our computer.
Here is this file and in order to transfer this file to a container we need to create volume mapping.
Same as we did with engine these containers.
Do remember that.
Let's do that no longer run this item.
And next comes volume.
Option desk view here.
I could use either absolute path to current folder Python folder that has Hello rolled by a file or
I could use.
Same as before.
B w d variable.
Let's use variable dollar assign B W.
Next comes column.
And afterwards we need to specify absolute path to internal folder inside of the container.
Recall that with engine X we have used actually default folder that was used for separating the different
files to clients but in such case we are actually able to use any folder you like we could use even
root folder but it's not a good practice to do so.
This way let's use a custom folder name for example slash up like so you could use any folder name you
like here and next comes name of the image.
Same as in this command in our case python.
And afterwards let's override default Python 3 command with custom command by then 3 and here we'll
be at name of the file.
Hello.
This rolled dot my question to you.
Will it work or not.
Let's try it.
Press enter again can't open file Hello rolled the API could you please find error in this comment.
If so please fix it yourself.
Great.
Let's fix it together.
And here instead of simply Hello World.
We need to specify path to Hello world API instead of the container.
Here we have mapped this folder to this folder and that's way here before.
File Name.
We need to specify slash up like so because now.
Hello world.
A file will be mapped from local folder by them into the app folder inside the container.
That's why here we need to specify this folder name as well.
Let's now execute this command enter.
And now I see Hello from the Python container.
Finally it works as expected.
Also we're actually able to get rid of this folder of graphics here by specifying an additional option
that double your working directory.
Let's do so.
Let's modify this command.
Let me remove up folder here and somewhere here.
After this the option let's add desk double your option.
That extends for walking directory.
And here let us simply type up like so last press enter and they see same result.
Hello from the Python container.
That's how we were able to successfully create the python container map volume from our local computer
to container and execute specific application file inside of the container.
Next you'll get a small challenge and you will need to create a bit more complicated program using Python
and executed inside of the Python container challenge task comes next.
My.