docker-compose未在docker容器

时间:2016-11-12 21:20:36

标签: docker docker-compose

我正在使用meanjs主代码中使用的所有Docker文件。什么都没有改变。

我使用命令

docker-compose up

在此之前我需要做什么吗?

我想知道如果我在一个文件中立即生成的更改会在docker容器上反映出来,那么为什么不在docker容器上复制或找到bower_components文件?

这是容器内的软件包列表。

image

在Container上bower.json文件是正确的。

image

这是bower.json

{
  "name": "meanjs",
  "description": "Fullstack JavaScript with MongoDB, Express, AngularJS, and Node.js.",
  "homepage": "http://meanjs.org/",
  "license": "MIT",
  "dependencies": {
    "angular": "~1.5.0",
    "angular-animate": "~1.5.0",
    "angular-bootstrap": "~1.2.1",
    "angular-messages": "~1.5.0",
    "angular-mocks": "~1.5.0",
    "angular-resource": "~1.5.0",
    "angular-ui-notification": "~0.2.0",
    "angular-ui-router": "~0.2.18",
    "bootstrap": "~3.3.6",
    "ng-file-upload": "^12.1.0",
    "ng-img-crop": "ngImgCrop#^0.3.2",
    "owasp-password-strength-test": "~1.3.0",
    "underscore": "^1.8.3",
    "angular-material": "^1.1.1",
    "angular-material-data-table": "^0.10.9",
    "material-design-icons": "^3.0.1",
    "angular-moment": "^1.0.0",
    "angular-aria": "^1.5.8"
  },
  "overrides": {
    "bootstrap": {
      "main": [
        "dist/css/bootstrap.css",
        "dist/css/bootstrap-theme.css",
        "less/bootstrap.less"
      ]
    },
    "jquery": {
      "main": []
    }
  }
}

Dockerfile取自此处:https://github.com/meanjs/mean/blob/master/Dockerfile

# Build:
# docker build -t meanjs/mean .
#
# Run:
# docker run -it meanjs/mean
#
# Compose:
# docker-compose up -d

FROM ubuntu:latest
MAINTAINER MEAN.JS

# 80 = HTTP, 443 = HTTPS, 3000 = MEAN.JS server, 35729 = livereload, 8080 = node-inspector
EXPOSE 80 443 3000 35729 8080

# Set development environment as default
ENV NODE_ENV development

# Install Utilities
RUN apt-get update -q  \
 && apt-get install -yqq \
 curl \
 git \
 ssh \
 gcc \
 make \
 build-essential \
 libkrb5-dev \
 sudo \
 apt-utils \
 && apt-get clean \
 && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Install nodejs
RUN curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
RUN sudo apt-get install -yq nodejs \
 && apt-get clean \
 && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Install MEAN.JS Prerequisites
RUN npm install --quiet -g gulp bower yo mocha karma-cli pm2 && npm cache clean

RUN mkdir -p /opt/mean.js/public/lib
WORKDIR /opt/mean.js

# Copies the local package.json file to the container
# and utilities docker container cache to not needing to rebuild
# and install node_modules/ everytime we build the docker, but only
# when the local package.json file changes.
# Install npm packages
COPY package.json /opt/mean.js/package.json
RUN npm install --quiet && npm cache clean

# Install bower packages
COPY bower.json /opt/mean.js/bower.json
COPY .bowerrc /opt/mean.js/.bowerrc
RUN bower install --quiet --allow-root --config.interactive=false

COPY . /opt/mean.js

# Run MEAN.JS server
CMD npm install && npm start

docker-compose.yml

version: '2'
services:
  web:
    restart: always
    build: .
    container_name: meanjs
    ports:
     - "3000:3000"
     - "5858:5858"
     - "8080:8080"
     - "35729:35729"
    environment:
     - NODE_ENV=development
     - DB_1_PORT_27017_TCP_ADDR=db
    depends_on:
     - db
    volumes_from:
     - web-data
  web-data:
    build: .
    entrypoint: /bin/true
    volumes:
     - ./:/opt/mean.js
     - /opt/mean.js/node_modules
     - /opt/mean.js/public
     - /opt/mean.js/uploads
  db:
    image: mongo:3.2
    restart: always
    ports:
     - "27017:27017"
    volumes_from:
      - db-data
  db-data:
    image: mongo:3.2
    volumes:
      - /data/db
      - /var/lib/mongodb
      - /var/log/mongodb
    entrypoint: /bin/true

运行docker-compose up命令时的输出:

docker-compose up

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:1)

由于某种原因它没有更新内容,所以我也删除了所有的docker容器和图像。现在它有效。