Search code examples
dockerubuntuterminal

Why these other py files not showing?


Its my code on write terminal for my push to my docker repo

I'm running and writing these codes, but they shouldn't work and I don't understand why they don't work. As a screen output, it should say hello 3 times one under the other, but it only says hello once. This the result but its false There needs to be two more of these screenshots

oh and i write this codes on terminal - ubuntu

How should I edit it to print 3 more Hello on the screen?

Short correction*: The application I made via the Ubuntu terminal was as follows: It would print 3 variables at once into a dockerfile, but I could not do this, so I consulted your answers to solve the problem. My goal was to write "hello \n" through 3 variables "hello\nhello" was to be printed, but since I failed to do this, I waited for your answer.


Solution

  • It seems like you do not use the python command correctly. If you want to run a script you use python [script] [args] which means in your case the script a.py get's called with the arguments [a2.py, a3.py].

    You can fix this by creating a main.py something like below calling your individual modules. And then in this main you can call functions and classes from these modules if you have them there.

    import a, a2, a3
    

    And then replacing your CMD in docker with:

    CMD ['python', 'main.py']