43
loading...
This website collects cookies to deliver better user experience
pyenv
if you:#Step 1
git clone <your-repo>.git
cd <your-repo>
# Step 2 & 3: creates container that is destroyed after session
docker run -it --rm --name python-runner -v "$PWD":/usr/src/myapp -w /usr/src/myapp python:3.7 bash
# OPTIONAL ALTERNATIVE> Step 2,3,& 3a: retain container between sessions
docker run -it --name <project-name> -v "$PWD":/usr/src/myapp -w /usr/src/myapp python:3.7 bash
# .... many hours later...
docker start -i <project-name>
# Step 4
# install dependencies following the directions based on your project
3.6, 3.7, 3.8, 3.9,
or 3.10
, but you can find every available option on Docker Hub. Your image will then be python:<chosen-version>
.docker run
command to create a transient container (swap version if needed). The bash
on the end, along with -it
tells Docker to give us an interactive shell, just like when you open a new terminal prompt. The -v
and -w
make the current directory available inside the container, so you’ll need to always run this command from the project.
--name
that you will recognize and remove the --rm
(which removes the container when the current run finishes). Now in the future, you can use docker start -i project-name
to pop open the shell, rather than needing to create a brand new container and install dependencies again.docker run
command, not on your local system.pip install --user -r requirement.txt
and you’re off the the races.pip install --user pipenv
# Ensure tool is available in your container's PATH
echo "export PATH=~/.local/bin:$PATH" >> ~/.bashrc
. ~/.bashrc # equivalent to 'source ~/.bashrc'
pipenv install --dev
curl -sSL <https://install.python-poetry.org> | python3 -
# Ensure tool is available in your container's PATH
echo "export PATH=~/.local/bin:$PATH" >> ~/.bashrc
. ~/.bashrc # equivalent to 'source ~/.bashrc'
poetry install
run
command to expose the port. Something like -p 8080:80 -p 443:443
is the recommended route to map <!-- raw HTML omitted -->:<!-- raw HTML omitted -->. Read more on StackOverflow.-i,--index-url
.