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 process of compiling and installing Storm on Kylin V10 server

1 Introduction Apache Storm is a free, open sourc...

MySQL Database Indexes and Transactions

Table of contents 1. Index 1.1 Concept 1.2 Functi...

How to switch directories efficiently in Linux

When it comes to switching directories under Linu...

Install and build a server environment of PHP+Apache+MySQL on CentOS

Yum (full name Yellow dog Updater, Modified) is a...

Linux common text processing commands and vim text editor

Today, let's introduce several common text pr...

Layim in javascript to find friends and groups

Currently, layui officials have not provided the ...

Detailed explanation of MySQL InnoDB secondary index sorting example

Sorting Problem I recently read "45 Lectures...

Summary of relevant knowledge points of ajax in jQuery

Preface Students who learn JavaScript know that A...

Realization of real-time file synchronization between Linux servers

Usage scenarios For existing servers A and B, if ...

Detailed explanation of the installation steps of the MySQL decompressed version

1. Go to the official website: D:\mysql-5.7.21-wi...

Teach you how to implement the observer mode in Javascript

Table of contents What is the Observer Pattern? S...