-
I read this #1879 (comment) , but it seems too complex, for a beginner like me. I tried, running $ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python - and this works perfectly in my machine (ubuntu) as well and docker containers running linux. But the thing is that, the above command requires to run For example: I create a Dockerfile: FROM python:3.9
WORKDIR /app
RUN apt-get update && apt-get upgrade -y
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
RUN bash -c "source $HOME/.poetry/env"
# RUN poetry --help # will be successful
# RUN poetry install # will succeed
CMD ["bash"]
Now I build the image: $ docker build --tag poetry-docker . Now, I run it in interactive mode: $ docker run -it poetry-docker
root@bb4c99c703e4:/app# poetry --version
bash: poetry: command not found
root@bb4c99c703e4:/app# source $HOME/.poetry/env
root@bb4c99c703e4:/app# poetry --version
Poetry version 1.1.5 If I stop the container, and start again, I again need to run the source command, to be able to use My questions:
basically, i want to publish my poetry-docker image to Dockerhub, and want to use it in my future projects like this: FROM aahnik/poetry-docker
RUN poetry --help # should succeed
... Update: Here https://python-poetry.org/docs/ get-poetry.py is used. But in README, it says deprecated? is my problem related to that ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
I changed my Dockerfile (see original above) to this, and it solves my issue of " How to add poetry to the path, once and for all?". But I am curious to know if my Dockerfile is all correct and safe for production. -RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
+RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python -
-RUN bash -c "source $HOME/.poetry/env"
+ENV PATH /root/.local/bin:$PATH |
Beta Was this translation helpful? Give feedback.
-
There is nothing obvious that is wrong here. Maybe cleanup after your
This is because
The live docs are related to the current stable version. The documentation on In a container you can also use |
Beta Was this translation helpful? Give feedback.
There is nothing obvious that is wrong here. Maybe cleanup after your
apt-get upgrade
.This is because
source <file>
only applies to the current shell, and eachRUN
executes in a new shell. To make it permanent, you can add the command to/etc/profile.d/poetry.sh
and also add bash completions if you so desired to/etc/bash_completion.d/poetry
.The live docs are related to the current stable version. The documentation…