Coder Social home page Coder Social logo

Comments (3)

twtrubiks avatar twtrubiks commented on May 20, 2024

因為 docker 可以透過容器的 service 連線到對應的 db, 我這邊剛好定義為 "db".
可參考 https://github.com/twtrubiks/docker-tutorial#user-defined-networks

透過內建的 DNS 伺服器,可以直接使用容器名稱,就可解析出 IP,不需要再使用 IP 讓容器互相
溝通,我們只需要知道容器的名稱就可以連接到容器。

from docker-swarm-tutorial.

hcgprague avatar hcgprague commented on May 20, 2024

from docker-swarm-tutorial.

twtrubiks avatar twtrubiks commented on May 20, 2024

我在 https://github.com/twtrubiks/docker-swarm-tutorial/blob/master/docker-swarm-secrets/api/django_rest_framework_tutorial/settings.py 這邊也是直接填入容器的名稱 (db).

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'postgres',
        'USER': 'postgres',
        'PASSWORD': secret('my_password'),
        'HOST': 'db',
        'PORT': 5432,
    }
}

不知道你問的是不是這個?

假如你有很多db, 理論上應該也會透過一些方法同步每一顆的db, 所以應該隨便拿一顆(應該 host 直接填入 db 即可).
再深入一點的我就沒有玩過了, 可能要 google 一下QQ

from docker-swarm-tutorial.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.