Quantcast
Channel: Node.jsタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 8691

node.jsをdocker-composeで動かしたら、Error: Cannot find module '/bash'になる

$
0
0

プログラミングを覚えて丁度1年くらいの未熟エンジニアがdeockerでnode.jsの環境構築をしてつまづいた話です。

  • Dockerfile
FROM node:14.5.0-alpine3.12WORKDIR /appCOPY . /appRUN npm install
  • docker-compose.yml
version:'3'services:app:build:.ports:-3000:3000tty:truevolumes:-.:/appcommand:bash -c "node index.js"depends_on:-dbdb:image:postgres:12.2ports:-"5432:5432"environment:-"POSTGRES_USER=hogehoge"-"POSTGRES_PASSWORD=hogehoge"-"POSTGRES_DB=hogehoge"

これを実行すると

Error: Cannot find module '/app/bash'

って言われます。

結論

alpineにbashは無いそうです。。
alpineは軽量で良いと言われ、使っていました。
ちゃんと調べないとダメですね。。

command:ash -c "node index.js"

docker-compose.ymlのcommandのところをbash => ashに変えたらOKでした


Viewing all articles
Browse latest Browse all 8691

Trending Articles