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

How to convert Chinese into UTF-8 in HTML

In HTML, the Chinese phrase “學好好學” can be express...

CentOS7 installation zabbix 4.0 tutorial (illustration and text)

Disable SeLinux setenforce 0 Permanently closed: ...

Automatically install the Linux system based on cobbler

1. Install components yum install epel-rpm-macros...

Use Python to connect to MySQL database using the pymysql module

Install pymysql pip install pymysql 2|0Using pymy...

Introduction to HTML link anchor tags and their role in SEO

The <a> tag is mainly used to define links ...

Teach you how to use docker-maven-plugin to automate deployment

1. Introduction to docker-maven-plugin In our con...

Detailed explanation of CentOS configuration of Nginx official Yum source

I have been using the CentOS purchased by Alibaba...

HTML embed tag usage and attributes detailed explanation

1. Basic grammar Copy code The code is as follows...

Semantics, writing, and best practices of link A

The semantics, writing style, and best practices ...

Common scenarios and avoidance methods for index failure in MySQL

Preface I have read many similar articles before,...

Vue implements 3 ways to switch tabs and switch to maintain data status

3 ways to implement tab switching in Vue 1. v-sho...

Detailed explanation of JavaScript upload file limit parameter case

Project scenario: 1. Upload file restrictions Fun...