Docker运行" pip install"和" npm install"在同一个容器上互相覆盖

时间:2015-08-16 21:27:32

标签: docker npm pip docker-compose

在我的docker容器中,我尝试使用pip安装多个软件包以及通过npm安装Bower。然而,似乎无论pip或npm中的哪一个先运行,/ usr / local / bin中的其他内容都会被覆盖(具体来说,下面的Dockerfile会丢失gunicorn,如果我交换了我的顺序,则Bower会丢失) FROM..RUN阻止)。

这是Docker的预期行为吗?如果是这样,我怎样才能将我的pip软件包和Bower安装到同一目录/ usr / local / bin中?

这是我的Dockerfile:

FROM python:3.4.3
RUN mkdir /code
WORKDIR /code
ADD ./requirements/ /code/requirements/
RUN pip install -r /code/requirements/docker.txt
ADD ./ /code/

FROM node:0.12.7
RUN npm install bower

这是我的docker-compose.yml文件:

web:
  restart: always
  build: .
  expose:
    - "8000"
  links:
    - postgres:postgres
    #-redis:redis
  volumes:
    - .:/code
  env_file: .env
  command: /usr/local/bin/gunicorn myapp.wsgi:application -w 2 -b :8000 --reload

webstatic:
  restart: always
  build: .
  volumes:
    - /usr/src/app/static
  env_file: .env
  command: bash -c "/code/manage.py bower install && /code/manage.py collectstatic --noinput"

nginx:
  restart: always
  #build: ./config/nginx
  image: nginx
  ports:
    - "80:80"
  volumes:
    - /www/static
    - config/nginx/conf.d:/etc/nginx/conf.d
  volumes_from:
    - webstatic
  links:
    - web:web

postgres:
  restart: always
  image: postgres:latest
  volumes:
    - /var/lib/postgresql
  ports:
    - "5432:5432"

更新:我继续将其作为docker-compose issue交叉发布,因为它不清楚是否存在实际错误或我的配置是否有问题。我会更新这两个帖子,但如果你知道发生了什么,请发帖。谢谢!

1 个答案:

答案 0 :(得分:3)

您无法在Dockerfile中使用多个FROM命令,也无法从2个不同的基本映像创建映像。因此,如果您需要在同一图像中使用node和python,您可以将节点添加到python图像或将python添加到节点图像。

相关问题