Home > Operation and Maintenance > Docker > How to run python script on docker

How to run python script on docker

王林
Release: 2020-03-25 11:18:18
Original
4493 people have browsed it

How to run python script on docker

First create a specific project directory for the docker image. For example:

mkdir /home/pi/Desktop/teasr/capturing
Copy after login

Copy the dockerfile and script 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
Copy after login

This is best practice because the first thing docker-engine does when building is read the entire current context.

Next we will look at your dockerfile. It should now look like this:

How to run python script on docker

The next thing you need to do is build it with a smart name, dots are generally discouraged.

docker build -t pulkit/capturing:1.0 .
Copy after login

The next step is to run the image as you did.

docker run -ti --name capturing pulkit/capturing:1.0
Copy after login

The script now executes inside the container and may exit when completed.

Note: The first line in the script needs to be #! /usr/bin/envpython.

Recommended tutorial: docker tutorial

The above is the detailed content of How to run python script on docker. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template