Python/Docker: Difference between revisions

From Fundamental Ramen
Jump to navigation Jump to search
Line 15: Line 15:


{| class="wikitable"
{| class="wikitable"
! || size || shell || vim
! || size || shell || vim || lxml
|-
|-
| python:{version} || 882MB || bash || X
| python:{version} || 882MB || bash || X || O
|-
|-
| python:{version}-slim || 113MB || bash || X
| python:{version}-slim || 113MB || bash || X || O
|-
|-
| python:{version}-alpine || 42.4MB || busybox (/bin/sh) || X
| python:{version}-alpine || 42.4MB || busybox (/bin/sh) || X || X
|}
|}



Revision as of 04:16, 17 December 2020

Test a docker image

Pull images

sudo docker pull python:3.8.6
sudo docker pull python:3.8.6-slim
sudo docker pull python:3.8.6-alpine
sudo docker images

python              3.8.6-alpine        8871758c6a8f        29 hours ago        42.4MB
python              3.8.6-slim          2be36bcc692b        29 hours ago        113MB
python              3.8.6               b4b9bf31ec03        29 hours ago        882MB
size shell vim lxml
python:{version} 882MB bash X O
python:{version}-slim 113MB bash X O
python:{version}-alpine 42.4MB busybox (/bin/sh) X X

Read platform infomations

sudo docker run --name py01 -it python:3.8.6
sudo docker run --name py01 -it python:3.8.6-slim
sudo docker run --name py01 -it python:3.8.6-alpine
>>> import platform
>>> platform.uname()
>>> platform.machine()
>>> exit()

List packages

sudo docker run --name py02 -it python:3.8.6 /bin/bash
sudo docker run --name py02 -it python:3.8.6-slim /bin/bash
sudo docker run --name py02 -it python:3.8.6-alpine /bin/sh
pip list

Package    Version
---------- -------
pip        20.3.3
setuptools 51.0.0
wheel      0.36.2

Do a scheduled job

sudo docker run --name py01 -it python:3.8.6-alpine /bin/sh
pip install schedule
vim start.py
python start.py