How can one Docker container call another Docker container

前端 未结 3 898
萌比男神i
萌比男神i 2021-02-05 21:08

I have two Docker containers

  1. A Web API
  2. A Console Application that calls Web API

Now, on my local web api is local host and Console applicat

3条回答
  •  [愿得一人]
    2021-02-05 21:49

    The problem can be solved easily if using compose feature. With compose, you just create one configuration file (docker-compose.yml) like this :

    version: '3'
    services:
      db:
        image: postgres
      web:
        build: .
        command: python3 manage.py runserver 0.0.0.0:8000
        volumes:
          - .:/code
        ports:
          - "8000:8000"
        depends_on:
          - db
    

    To make it run, just call up like this :

    docker-compose up 
    

    This is the best way to run all your stack, so, check this reference : https://docs.docker.com/compose/

    Success!

提交回复
热议问题