Skip to content

Creates a single Docker container that lets your run both Python 2.7.13 and Python 3.6.0

License

Notifications You must be signed in to change notification settings

cclauss/Python2-and-Python3-in-Docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Python2-and-Python3-in-Docker

Creates a single Docker container lets you run both Python 2.7.13 and Python 3.7.1

TL;DR:$ docker build -t python-2-and-3 .

Starts withpython:3.7.1-alpineand then installs most ofpython:2.7.13-alpineon top to allow you to choose either Python version at runtime via: python2, python3, pip2, pip3

NOTE: site-packages are separate sopip2 install pkgnamedoes not makepkgnameavailable to Python 3. This means that you would also need topip3 install pkgnameto makepkgnameaccessable from both versions of Python.

$ mkdir python-2-and-3
$ cd python-2-and-3

# <put `Dockerfile` into that directory...>
$ docker build -t python-2-and-3 .
$ docker images  # python-2-and-3 should be at the top of the list

# Do some optional interactive testing...
$ docker run -it python-2-and-3 /bin/sh
\# python  -V  # Python 2.7.13
\# python2 -V  # Python 2.7.13
\# python3 -V  # Python 3.6.0

\# pip  -V     # pip 9.0.1 from /usr/local/lib/python2.7/site-packages (python 2.7)
\# pip2 -V     # pip 9.0.1 from /usr/local/lib/python2.7/site-packages (python 2.7)
\# pip3 -V     # pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)

\# SCRIPT="import platform ; print(platform.python_version())"
\# python  -c "$SCRIPT"  # 2.7.13
\# python2 -c "$SCRIPT"  # 2.7.13
\# python3 -c "$SCRIPT"  # 3.6.0

\# exit
$

About

Creates a single Docker container that lets your run both Python 2.7.13 and Python 3.6.0

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published