How to run python script on docker
This article mainly introduces how to run the python script on docker. It is very detailed and has certain reference value. If you are interested, you must finish it.
What are the five characteristics of python? what are the five characteristics of python: 1. It's easy to learn, and when you develop a program, you focus on solving problems, not understanding the language itself. two。 Object-oriented, compared with other major languages such as C++ and Java, Python implements object-oriented programming in a very powerful and simple way. 3. Portability, Python programs can run on a variety of platforms without modification. 4. Explanation, programs written in Python do not need to be compiled into binary code and can be run directly from the source code. 5. Open source, Python is one of FLOSS (Free / Open Source Software).
First create a specific project directory for the docker image. For example:
Mkdir / home/pi/Desktop/teasr/capturing
Copy the dockerfile and scripts there and change the current context to this directory
Cp / home/pi/Desktop/teasr/capturing.py / home/pi/Desktop/teasr/dockerfile / home/pi/Desktop/teasr/capturing/cd / home/pi/Desktop/teasr/capturing
This is a best practice because the first thing docker-engine does when building is to read the entire current context.
Next we'll take a look at your dockerfile. Now it should look like this:
The next thing you need to do is to build it with smart names, usually discouraging the use of dots.
Docker build-t pulkit/capturing:1.0.
The next step is to run the image like you do.
Docker run-ti-- name capturing pulkit/capturing:1.0
The script is now executed in the container and may exit when it is complete.
Note: the first line in the script needs to be #! / usr/bin/env python .
The above is all the content of the article "how python scripts run on docker". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!