简体   繁体   中英

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. My problem is that it only starts postgres image, but express app is not running.

What am I doing wrong?

I've published it on my 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.

if that is the case, you need to modify the compose file and tell it to build an image based on the 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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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