Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/301.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在Docker中使用多种编程语言?_Python_Node.js_Docker - Fatal编程技术网

Python 如何在Docker中使用多种编程语言?

Python 如何在Docker中使用多种编程语言?,python,node.js,docker,Python,Node.js,Docker,我的项目是用Node.js编写的,运行一个需要构建的Python文件。以前,我在从GitHub中提取时使用了一个脚本来设置项目。我想改用Docker,但在运行多个From时遇到问题。我的理解是FROM创建了一个新的映像,正是由于这个原因,我的项目构建失败了。解决这个问题的办法是什么 原始Shell脚本 yarn git clone https://github.com/<directory> mv <directory> <new_name> cd <d

我的项目是用Node.js编写的,运行一个需要构建的Python文件。以前,我在从GitHub中提取时使用了一个脚本来设置项目。我想改用Docker,但在运行多个From时遇到问题。我的理解是FROM创建了一个新的映像,正是由于这个原因,我的项目构建失败了。解决这个问题的办法是什么

原始Shell脚本

yarn
git clone https://github.com/<directory>
mv <directory> <new_name>
cd <directory>
virtualenv venv
source venv/bin/activate
pip3 install -r requirements.txt 
纱线
git克隆https://github.com/
mv
光盘
虚拟的
源venv/bin/激活
pip3安装-r requirements.txt
尝试的Dockerfile

FROM python:3.6

RUN mkdir -p /usr/src/app

COPY . /usr/src/app/
WORKDIR /usr/src/app

RUN git clone https://github.com/<directory>
RUN mv /usr/src/app/<directory> /usr/src/app/<new_name>

RUN pip3 install -r <new_name>/requirements.txt

FROM node:11

WORKDIR /usr/src/app

RUN npm install --production

EXPOSE 3000
ENTRYPOINT npm start
来自python:3.6的

运行mkdir-p/usr/src/app
抄袭/usr/src/app/
WORKDIR/usr/src/app
运行git克隆https://github.com/
运行mv/usr/src/app//usr/src/app/
运行pip3安装-r/requirements.txt
从节点:11
WORKDIR/usr/src/app
运行npm安装--生产
暴露3000
入口点npm启动

您必须使用任何一个映像,然后在该映像中安装其他应用程序。因此,您的dockerfile可能如下所示:

FROM node:11

RUN mkdir -p /usr/src/app

COPY . /usr/src/app/
WORKDIR /usr/src/app

RUN git clone https://github.com/<directory>
RUN mv /usr/src/app/<directory> /usr/src/app/<new_name>

RUN Command to install python 3.6 and pip3

RUN pip3 install -r <new_name>/requirements.txt

WORKDIR /usr/src/app

RUN npm install --production

EXPOSE 3000
ENTRYPOINT npm start
来自节点:11
运行mkdir-p/usr/src/app
抄袭/usr/src/app/
WORKDIR/usr/src/app
运行git克隆https://github.com/
运行mv/usr/src/app//usr/src/app/
运行命令安装python 3.6和pip3
运行pip3安装-r/requirements.txt
WORKDIR/usr/src/app
运行npm安装--生产
暴露3000
入口点npm启动

你可以参考这个。

你不能像那样组合两个图像。你有一些选择:1。将Python安装到节点映像中。2.在Python映像3中安装节点。将两者都安装到基本映像中,如Debian或Alpine。我想添加到@KlausD。清单4。谷歌“docker python and node”,看看是否已经有图像在做你需要的事情,最后使用python:3.6中的
,然后安装node。成功,谢谢!