- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个包含三个服务的 docker-compose.yml:一个 Node 应用程序、一个 Mongo 数据库和 waisbrot/wait在启动应用程序之前等待 Mongo 服务器开始监听。
当我运行 docker-compose up
时,compose 立即开始构建并启动应用程序服务,而不是先启动其依赖项。我在控制台没有得到任何输出,表明 compose 正在尝试启动其他任何一个容器。
堆栈无法启动,因为应用服务器在无法连接到 Mongo 时崩溃。
这是我的docker-compose.yml
:
version: '2'
services:
wait:
image: waisbrot/wait
depends_on:
- mongo
environment:
- TARGETS=mongo:27017
app:
build: .
depends_on:
- wait
mongo:
image: mongo:3.2
volumes:
- /data/db
我的意图是首先启动 mongo 服务,然后启动等待服务,最后启动应用程序。查看输出甚至查看 docker stats
,似乎只有应用程序服务正在启动。这是 docker-compose up
的输出:
Building app
Step 1 : FROM node:6.6
---> c0d8845263e3
Step 2 : COPY ./package.json /app/package.json
---> Using cache
---> db47c6c65663
Step 3 : WORKDIR /app/
---> Using cache
---> 30c3cadc2680
Step 4 : RUN npm i
---> Using cache
---> 5ae6a18b2100
Step 5 : COPY ./src/ /app/src/
---> Using cache
---> dd64329a5fe2
Step 6 : COPY ./config/ /app/config/
---> Using cache
---> 1945706cdaac
Step 7 : COPY ./public/ /app/public/
---> Using cache
---> af6f6b7075c1
Step 8 : EXPOSE 3030
---> Using cache
---> 4ecec8df6ef7
Step 9 : RUN npm start
---> Running in 04a543b58d85
npm info it worked if it ends with ok
npm info using npm@3.10.3
npm info using node@v6.6.0
npm info lifecycle family-communication@0.0.0~prestart: family-communication@0.0.0
npm info lifecycle family-communication@0.0.0~start: family-communication@0.0.0
> family-communication@0.0.0 start /app
> node src/
Feathers application started on localhost:3030
/app/node_modules/mongodb/lib/server.js:261
process.nextTick(function() { throw err; })
^
MongoError: failed to connect to server [mongo:27017] on first connect
at Pool.<anonymous> (/app/node_modules/mongodb-core/lib/topologies/server.js:313:35)
at emitOne (events.js:96:13)
at Pool.emit (events.js:188:7)
at Connection.<anonymous> (/app/node_modules/mongodb-core/lib/connection/pool.js:260:12)
at Connection.g (events.js:291:16)
at emitTwo (events.js:106:13)
at Connection.emit (events.js:191:7)
at Socket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:162:49)
at Socket.g (events.js:291:16)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at connectErrorNT (net.js:1015:8)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
npm info lifecycle family-communication@0.0.0~start: Failed to exec start script
npm ERR! Linux 4.4.20-moby
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v6.6.0
npm ERR! npm v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! family-communication@0.0.0 start: `node src/`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the family-communication@0.0.0 start script 'node src/'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the family-communication package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node src/
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs family-communication
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls family-communication
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /app/npm-debug.log
ERROR: Service 'app' failed to build: The command '/bin/sh -c npm start' returned a non-zero code: 1
为什么这不像我预期的那样工作?
最佳答案
RUN npm start
Dockerfile 中的该命令实际上是在构建 时启动您的网络服务器,此时其他容器尚不存在。也许你想要
CMD npm start
关于docker-compose 忽略 depends_on 建立的启动顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39735466/
我使用以下命令使用 Composer 删除了一个包。 composer remove sjparkinson/static-review 以上命令从 composer.json 中删除条目文件但 co
我刚刚开始使用 Composer 功能,你告诉它查看本地目录的依赖关系,这样你就可以开发一个库和一些并行使用该库的东西,而不必一直推送到 git 来更新,这是惊人的。例如 "repositories"
composer 和有什么区别和 composer.phar ? 例子: composer install composer.phar install 我一直看到使用 composer.phar 编写
阅读docker-compose -h或this official manual的帮助将为我们提供--project-directory PATH选项 docker-compose [-f ...]
我已经使用他们的安装指南在我的 Linux/Apache 服务器上的根目录(这是默认选择)中成功安装了 Composer。到目前为止,一切都非常简单,除了我必须进行的一个 php.ini 调整( de
在我的 composer.json配置文件,我有: "require": { "zendframework/zend-log" : "~2.3", }, "require-dev": {
从 Composer 安装此软件包后,我想复制位于软件包内的一些文件。 实际上,我希望在从 Composer 安装或更新软件包后,将下载的软件包中可能存在的某个文件复制到另一个目录。我用 script
我对码头公司还是个新手。我使用的是最新版本的Python、Django和Docker。我已经在这个项目上工作了两周了,我已经创建了docker-compose.yml文件,并且已经构建了我的docke
我正在尝试使用 composer 安装一个 github 项目并得到以下错误 Composer [UnexpectedValueException]您的 github.com 的 Github oau
我开发 Symfony 包的工作流程如下: 安装 Symfony 为新包创建一个 git repo,在其中放置一个 composer.json 文件 需要顶级 composer.json 中的新包,使
我正在尝试使用 composer 安装 github 项目并收到以下错误 Composer [UnexpectedValueException] 您用于 github.com 的 Github oau
我们在项目中使用了 composer。当我开发和/或向项目提交任何内容时,我通常应该使用 composer install;更新依赖项只是偶尔进行。 我们还使用 https://github.com/
我在 youtube 上学会了这个抽屉 https://www.youtube.com/watch?v=JLICaBEiJS0&list=PLQkwcJG4YTCSpJ2NLhDTHhi6XBNfk9
我知道在 onClick 中调用可组合函数是不可能的。 @Composable 调用只能在 @Composable 函数的上下文中发生 撰写版本 - alpha06 但我坚持以下要求。 要求是, 在
这是我的 docker-compose.yml 文件: version: '3.1' services: a: image: tutum/hello-world b: imag
创建Asset实例时是否有auto_increment字段类型可用。例如, Assets ID 应该是自动生成的字段,应该在运行时创建,而不是在应用程序级别提及该值。我可以通过创建一个交易处理器函数来
在 Composer 项目中,我必须添加一个库,它没有 composer.json 并且不使用命名空间。因此,我调整了项目的 composer.json 以添加库: { [...] "
当 vendor 目录中已经有一些组件被下载时.. 在上面运行 install 以及运行 update 时有什么影响? 最佳答案 所以我有同样的问题,这是我发现的: composer install
尝试运行 composer install 时出现此错误。我已经运行了 composer update,我正在尝试使用这个最新的锁定文件进行安装。没有任何帮助。 Loading composer re
当我尝试做: $ sudo php composer.phar update 我收到此警告: Warning: This development build of composer is over 3
我是一名优秀的程序员,十分优秀!