Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to run python script on docker

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report