docker pull to also get postgres dependency image?

Viewed 106

New to Docker

Background: I have written a docker-compose.yml which when run with docker-compose up will build and run nicely on my box. Note: my docker-compose.yml downloads the Postgres image.

version: '3'

services:
  api:
     image: conference_api 
     container_name: conference_api
     build:
       context: .
     ports:
       - 5000:80
     environment:
       ASPNETCORE_ENVIRONMENT: Production
     depends_on:
       - postgres
  postgres:
    image: postgres:9.6.3
    container_name: conference_db
    environment:
      POSTGRES_DB: conference
      POSTGRES_USER: conf_app
      POSTGRES_PASSWORD: docker
    ports:
      - 5432:5432
    volumes:
      - ./db:/docker-entrypoint-initdb.d

I then publish my docker image to docker hub.

On a fresh machine I use docker pull to pull my image and then I run it.

I get errors saying bascially "I can't find the database". The Postgres Image was not also downloaded.

My Question: When I pull my image, how can I get the Postgres image to also download as it is a dependency of my Image.

1 Answers
Related