简体   繁体   English

Docker-compose 启动单个容器

[英]Docker-compose starts a single container

I'm using docker-compose and I'm trying to run an express app and postgres db in docker containers.我正在使用 docker-compose 并且我正在尝试在 docker 容器中运行快速应用程序和 postgres db。 My problem is that it only starts postgres image, but express app is not running.我的问题是它只启动 postgres 图像,但 express 应用程序没有运行。

What am I doing wrong?我究竟做错了什么?

I've published it on my github: https://github.com/ayakymyshyn/docker-playground我已经在我的 github 上发布了它: https://github.com/ayakymyshyn/docker-playground

looking at your docker-compose file and Dockerfile , i assume that your intention is that the web service in the compose will actually run the image produced by the Dockerfile. looking at your docker-compose file and Dockerfile , i assume that your intention is that the web service in the compose will actually run the image produced by the Dockerfile.

if that is the case, you need to modify the compose file and tell it to build an image based on the Dockerfile.如果是这种情况,您需要修改 compose 文件并告诉它基于 Dockerfile 构建图像。

it should look something like它应该看起来像

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'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM