pipenv -- docker 的系统选项。在 docker 中获取所有 python 包的建议方法是什么
pipenv --system option for docker. What is the suggested way to get all the python packages in docker
我的 django
应用程序使用 pipenv
。
$ mkdir djangoapp && cd djangoapp
$ pipenv install django==2.1
$ pipenv shell
(djangoapp) $ django-admin startproject example_project .
(djangoapp) $ python manage.py runserver
现在我正在转向 docker 环境。
根据我的理解 pipenv
只在 virtualenv
中安装包
您不需要容器内的虚拟环境,docket 容器本身就是一个虚拟环境。
后来,在浏览了许多 Docker 文件后,我发现 --system
选项可以安装到系统中。
例如我发现的以下内容:
https://testdriven.io/blog/dockerizing-django-with-postgres-gunicorn-and-nginx/
COPY ./Pipfile /usr/src/app/Pipfile
RUN pipenv install --skip-lock --system --dev
https://hub.docker.com/r/kennethreitz/pipenv/dockerfile
# -- Install dependencies:
ONBUILD RUN set -ex && pipenv install --deploy --system
https://wsvincent.com/beginners-guide-to-docker/
# Set work directory
WORKDIR /code
# Copy Pipfile
COPY Pipfile /code
# Install dependencies
RUN pip install pipenv
RUN pipenv install --system
所以 --system
就足够了,或者 --deploy --system
是更好的方法。 --skip-lock --system --dev
又不一样了。
有人可以指导如何让我的环境恢复到我的 Docker
一个典型的 Docker 部署会涉及到有一个 requirements.txt
(它是一个 file where you can store your pip dependencies, including Django itself)文件,然后在你的 Dockerfile
中你做这样的事情:
FROM python:3.7 # or whatever version you need
ADD requirements.txt /code/
WORKDIR /code
# install your Python dependencies
RUN pip install -r requirements.txt
# run Django
CMD [ "python", "./manage.py", "runserver", "0.0.0.0:8000"]
你根本不需要pipenv
,因为你不再有你所说的虚拟环境。
更好的是,您可以在 docker-compose.yml
文件中配置很多东西,然后使用 docker-compose
到 运行 并管理您的服务,而不仅仅是 Django。
Docker have a very good tutorial on dockerising Django with it. And if you're unsure what's going on in the Dockerfile
itself, check the manual.
我的 django
应用程序使用 pipenv
。
$ mkdir djangoapp && cd djangoapp
$ pipenv install django==2.1
$ pipenv shell
(djangoapp) $ django-admin startproject example_project .
(djangoapp) $ python manage.py runserver
现在我正在转向 docker 环境。
根据我的理解 pipenv
只在 virtualenv
您不需要容器内的虚拟环境,docket 容器本身就是一个虚拟环境。
后来,在浏览了许多 Docker 文件后,我发现 --system
选项可以安装到系统中。
例如我发现的以下内容:
https://testdriven.io/blog/dockerizing-django-with-postgres-gunicorn-and-nginx/
COPY ./Pipfile /usr/src/app/Pipfile
RUN pipenv install --skip-lock --system --dev
https://hub.docker.com/r/kennethreitz/pipenv/dockerfile
# -- Install dependencies:
ONBUILD RUN set -ex && pipenv install --deploy --system
https://wsvincent.com/beginners-guide-to-docker/
# Set work directory
WORKDIR /code
# Copy Pipfile
COPY Pipfile /code
# Install dependencies
RUN pip install pipenv
RUN pipenv install --system
所以 --system
就足够了,或者 --deploy --system
是更好的方法。 --skip-lock --system --dev
又不一样了。
有人可以指导如何让我的环境恢复到我的 Docker
一个典型的 Docker 部署会涉及到有一个 requirements.txt
(它是一个 file where you can store your pip dependencies, including Django itself)文件,然后在你的 Dockerfile
中你做这样的事情:
FROM python:3.7 # or whatever version you need
ADD requirements.txt /code/
WORKDIR /code
# install your Python dependencies
RUN pip install -r requirements.txt
# run Django
CMD [ "python", "./manage.py", "runserver", "0.0.0.0:8000"]
你根本不需要pipenv
,因为你不再有你所说的虚拟环境。
更好的是,您可以在 docker-compose.yml
文件中配置很多东西,然后使用 docker-compose
到 运行 并管理您的服务,而不仅仅是 Django。
Docker have a very good tutorial on dockerising Django with it. And if you're unsure what's going on in the Dockerfile
itself, check the manual.