How to run Python script on Docker

How to run Python script on Docker

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

mkdir /home/pi/Desktop/teasr/capturing

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

This is 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. It should now look like this:

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

docker build -t pulkit/capturing:1.0 .

Next is to run the image like you did.

docker run -ti --name capturing pulkit/capturing:1.0

The script is now executed inside the container and may exit when finished.

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

This is the end of this article about how to run Python scripts on Docker. For more information about how to run Python scripts on Docker, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to build a deep learning environment running Python in Docker container
  • How to create a basic image of the Python runtime environment using Docker
  • Using Docker to run a simple Python program

<<:  Implementing a simple calculator with javascript

>>:  Advanced and summary of commonly used sql statements in MySQL database

Recommend

Convert XHTML CSS pages to printer pages

In the past, creating a printer-friendly version ...

Book page turning effects made with CSS3

Result:Implementation code: html <!-- Please h...

Analysis of the reasons why MySQL's index system uses B+ tree

Table of contents 1. What is an index? 2. Why do ...

htm beginner notes (must read for beginners)

1. What is HTML HTML (HyperText Markup Language):...

MySQL learning notes help document

View system help help contents mysql> help con...

Detailed explanation of using JavaScript WeakMap

A WeakMap object is a collection of key/value pai...

JavaScript implements class lottery applet

This article shares the specific code of JavaScri...

Detailed steps to install nginx on Apple M1 chip and deploy vue project

brew install nginx Apple Mac uses brew to install...

Detailed explanation of the seven data types in JavaScript

Table of contents Preface: Detailed introduction:...

Linux 6 steps to change the default remote port number of ssh

The default ssh remote port in Linux is 22. Somet...

Share a Markdown editor based on Ace

I think editors are divided into two categories, ...

Detailed explanation of MySQL information_schema database

1. Overview The information_schema database is th...

CSS style to center the HTML tag in the browser

CSS style: Copy code The code is as follows: <s...