Docker-Compose Up Demo

When running docker-compose on older version of YAML for voting machine, the docker-compose up throws an error where it states that

ERROR: for worker  Cannot start service worker: Cannot link to a non running container: /example-voting-app_db_1 AS /example-voting-app_worker_1/db

ERROR: for result  Cannot start service result: Cannot link to a non running container: /example-voting-app_db_1 AS /example-voting-app_result_1/db_1

YAML File is

redis:

  image: redis

db:

  image: postgres:9.6-alpine

vote:

  image: voting-app

  ports:

    - 5000:80

  links:

    - redis

worker:

  image: worker-app

  links:

    - redis

    - db

  

result:

  image: result-app

  ports:

    - 5001:80

  links:

    - db

try this yaml
Please, try this yaml

version: "3"
services: 
  redis: 
    image: redis
 
  db:
    image: postgres:9.4
 
  vote: 
    image: voting-app
    ports:
      - 5000:80
    links:
      - redis
 
  worker:
    image: httpd 
    depends_on:
      - redis
      - db
    links:
      - redis
      - db
 
  result: 
    image: nginx
    depends_on:
      - db
    ports:
      - 5001:80
    links:
      - db

The result page is not working. Instead of showing result, it show me this:

I replicated the same issue. I think the problem is that in the docker-compose.yml file in the first demo (using old compose version) the user/pass of the db is not set. In my case I solved it by adding those to the yml file:

redis:
  image: redis

db:
  image: postgres:9.4
  environment:
    - POSTGRES_PASSWORD=postgres
    - POSTGRES_USER=postgres

vote:
  image: voting-app
  ports:
    - 5000:80
  links:
    - redis

worker:
  image: worker-app
  links:
    - db
    - redis

result:
  image: result-app
  ports:
    - 5001:80
  links:
    - db