如何设置从图像ubuntu安装docker的python路径

2024-04-20 12:32:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我从ubuntu:18.04制作了这个映像并安装了python

但是当我在docker compose中这样做的时候

command: python manage.py runserver

它显示了路径错误

也许我没有设定路线

但是我如何为docker用户设置路径

ERROR: for django  Cannot start service django: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"python\": executable file not found in $PATH": unknown
ERROR: Encountered errors while bringing up the project.


FROM ubuntu:18.04

ENV PYTHONUNBUFFERED 1

RUN apt-get -y update
RUN apt-get -y install emacs wget

RUN apt-get -y install apache2-dev mysql-client
RUN apt-get -y install mysql-server libmysqlclient-dev

RUN apt-get install -y software-properties-common
RUN add-apt-repository -y ppa:deadsnakes/ppa
RUN apt-get install -y python3.7

RUN apt-get install -y python-pip
RUN pip install uwsgi django mysqlclient tensorflow_hub django-mysql django-extensions djangorestframework django-filter requests_oauthlib mecab-python3 neologdn gensim janome --no-input
RUN pip install keras tensorflow==1.14.0 --no-cache-dir --no-input

RUN mkdir /code
WORKDIR /code

ADD ./src /code/

Tags: installpipdjangodockernorundev路径
1条回答
网友
1楼 · 发布于 2024-04-20 12:32:41

你可以用两种方法解决这个问题(对我来说很有效):

在docker compose中添加:

command: bash -c 'python manage.py runserver'

也可以在Dockerfile中添加CMD命令:

CMD: python manage.py runserver

相关问题 更多 >