-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Bahrami edited this page Mar 2, 2023
·
1 revision
Welcome to the python-docker wiki!
an example based on the official instructions at https://docs.docker.com/language/python/
$ python3 -m venv .venv
$ source .venv/bin/activate
$ python3 -m pip install numpy
$ python3 -m pip freeze > requirements.txt
touch hello-py-docker.py
open vscode and add a code like
import numpy as np
A = np.array([1 , 2])
print("Hello World!")
print(f'A = {A}')
(.venv) mo@Ryans-MBP python-docker % python3 hello-py-docker.py # test the code
deactivate and build
(.venv) mo@Ryans-MBP python-docker % deactivate
mo@Ryans-MBP python-docker % docker build --tag py-docker .
run the code within the containder
docker run py-docker python3 hello-py-docker.py