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

Detailed steps to install and uninstall Apache (httpd) service on centos 7

uninstall First, confirm whether it has been inst...

Detailed explanation of XML syntax

1. Documentation Rules 1. Case sensitive. 2. The a...

Steps to modify the MySQL database data file path under Linux

After installing the MySQL database using the rpm...

JavaScript selector functions querySelector and querySelectorAll

Table of contents 1. querySelector queries a sing...

9 Practical CSS Properties Web Front-end Developers Must Know

1. Rounded Corners Today's web designs are con...

Vendor Prefix: Why do we need a browser engine prefix?

What is the Vendor Prefix? Vendor prefix—Browser ...

Nginx rtmp module compilation arm version problem

Table of contents 1. Preparation: 2. Source code ...

MySQL 5.7.17 installation and configuration method graphic tutorial under win7

I would like to share with you the graphic tutori...

Detailed explanation of MySQL database index

Table of contents 1. Introduction to MySQL Index ...

Detailed explanation of the cache implementation principle of Vue computed

Table of contents Initialize computed Dependency ...

MySQL series of experience summary and analysis tutorials on NUll values

Table of contents 1. Test Data 2. The inconvenien...