How to create a basic image of the Python runtime environment using Docker

How to create a basic image of the Python runtime environment using Docker

1. Preparation

1.1 Download the Python installation package (Note: the Python version can be changed according to your needs)

Download from official website: https://www.python.org/downloads/source/

Local download address: 64-bit: https://www.jb51.net/softs/416037.html

32-bit: https://www.jb51.net/softs/543679.html

1.2Base image Ubuntu16.04

DockerHub pull

docker pull ubuntu:16.04

Local Ubuntu download address: https://www.jb51.net/softs/532597.html

docker load < ubuntu1604.tar

2. Production process

2.1 Dockerfile Writing

FROM ubuntu:16.04
MAINTAINER cc-man
#Add Python installation package ADD Python-3.5.0.tar.xz /opt 
#Update apt
RUN apt-get update && apt-get install -y 
#Install dependencies RUN apt-get install gcc -y && apt-get install make -y \
		&& apt-get install vim -y && apt-get install openssl -y \
		&& apt-get install libssl-dev -y && apt-get install python3-pip -y
RUN ./opt/Python-3.5.0/configure --prefix=/usr/local/python3.5 \
		&& make && make install
RUN mkdir /opt/myApp/
VOLUME ["/opt/myApp/"]
CMD [""]

Note: The python version can be changed according to your needs

2.2 Production

docker build -t ubuntu-16.04/python:3.5 .

Note: The image creation process requires downloading dependencies so you need to wait for a while.

insert image description here

success:

insert image description here

2.3 View the image

2.3.0 View

docker images 

insert image description here

2.3.1 Entering the image

1. Enter the container

docker run -i -t -v /root/software/:/mnt/software/ 117cbe7ba93b /bin/bash

2. Check the pip version

pip -V 

insert image description here

3. Run Python

1.1

python3.5

1.2

print("hello world") 

insert image description here

At this point we have completed the production of the Python basic environment image

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • How to build a deep learning environment running Python in Docker container
  • How to run Python script on Docker
  • Using Docker to run a simple Python program

<<:  A brief introduction to the command line tool mycli for operating MySQL database

>>:  Use native js to simulate the scrolling effect of live bullet screen

Recommend

Zen coding for editplus example code description

For example, he enters: XML/HTML Code div#page>...

Vue uses rules to implement form field validation

There are many ways to write and validate form fi...

MySQL learning to create and operate databases and table DDL for beginners

Table of contents 1. Operate the database 1.1 Cre...

WeChat applet implements user login module server construction

I chose node.js to build the server. Friends who ...

The difference between html empty link href="#" and href="javascript:void(0)"

# contains a location information. The default anc...

How to migrate mysql storage location to a new disk

1. Prepare a new disk and format it with the same...

CSS to achieve chat bubble effect

1. Rendering JD Effect Simulation Effect 2. Princ...

Application of Beautiful Style Sheets in XHTML+CSS Web Page Creation

This is an article written a long time ago. Now it...

How to solve the problem that the project in eclipse cannot be added to tomcat

1. Right-click the project and select properties ...

The whole process of realizing website internationalization using Vite2 and Vue3

Table of contents Preface Install vue-i18n Config...

Some settings of Div about border and transparency

frame: Style=”border-style:solid;border-width:5px;...

What does href=# mean in a link?

Links to the current page. ------------------- Com...

js to achieve the effect of dragging the slider

This article shares the specific code of how to d...