我正在使用docker-compose,我正试图在docker容器中运行express应用程序和postgres db。我的问题是,它只启动postgres图像,但express应用程序没有运行。
我做错了什么?
我已经在我的github上发布了:https://github.com/ayakymyshyn/docker-playground
查看您的docker-compose文件和Dockerfile,我假设您的意图是compose中的web
服务将实际运行由Dockerfile生成的图像。
如果是这种情况,您需要修改撰写文件,并告诉它基于Dockerfile构建一个映像。
应该看起来像
version: "3.7"
services:
web:
image: node
build: . # <--- this is the missing line
depends_on:
- db
ports:
- '3001:3001'
db:
image: postgres
environment:
POSTGRES_PASSWORD: 123123123
POSTGRES_USER: yakym
POSTGRES_DB: jwt
volumes:
- ./pgdata:/var/lib/postgresql/data
ports:
- '5433:5433'