New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connect to database outside Docker #140
Comments
@iho Because hasura is connecting from inside the docker container, you'll have to change HOST_IP in the command below:
|
Are you on a mac/linux/windows machine? Can you paste your |
@coco98 thank you for fast response! I tried 172.17.0.1, but it does not work too.
Solved with |
Thanks @iho. We'll update the docs asap too :) |
Please look at this answer https://stackoverflow.com/a/26090569 |
@coco98 |
@iho migration files in the |
@rikinsk Can you update the docs per: https://stackoverflow.com/questions/17770902/forward-host-port-to-docker-container/26090569#26090569 Especially for this page I think: https://docs.hasura.io/1.0/graphql/manual/deployment/docker/index.html |
Close when docs issue is closed. |
hasura/graphql-engine-docs#32 is closed |
@iho We have updated docs with |
How can I make this using docker-compose.yml? |
@shahidhk docker-compose is my question too. |
@andresespinosapc, @mnlbox: I believe I have found a way. Edit /etc/hasura/docker-compose.yml to include ports: in the then restart the containers by doing
from the If it worked, you should see a new port being forwarded when you run |
@andresespinosapc @mnlbox @dsmurrell @iho version: '3.7'
services:
db:
image: postgres
restart: always
environment:
POSTGRES_DB: '${DB_DATABASE}'
POSTGRES_USER: '${DB_USERNAME}'
POSTGRES_PASSWORD: '${DB_PASSWORD}'
# "ports" setting is not required to let hasura connent to db.
# Whether to expose it or not is optional.
# But it's required if your application needs direct access(not through hasura) to db.
ports:
- target: 5432
published: ${DB_PORT}
protocol: tcp
mode: host
volumes:
# Uncomment the below if you want to execute .sh or .sql files on bootstrapping.
# Visit official postgress docker page for more detail.
# - ./data:/docker-entrypoint-initdb.d
- db_data:/var/lib/postgresql/data
graphql-engine:
image: hasura/graphql-engine
ports:
- target: 8080
published: ${HASURA_PORT}
protocol: tcp
mode: host
depends_on:
- 'db'
restart: always
environment:
HASURA_GRAPHQL_DATABASE_URL: 'postgres://${DB_USERNAME}:${DB_PASSWORD}@db:${DB_PORT}/${DB_DATABASE}'
HASURA_GRAPHQL_ENABLE_CONSOLE: 'true' # set to "false" to disable console
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
## uncomment next line to set an admin secret
# HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey
volumes:
db_data: Where And please note that there is "db" after "@", which is not "localhost", in As "db" is a service name of postgres in this docker compose file, |
Here's another example of a working The changes are:
Once you've added this |
Hi Team, |
@jjangga0214 |
@ukanwat They should be numbers. like For example, graphql-engine:
image: hasura/graphql-engine
ports:
- target: 8080
published: 9090 # This is what you should configure
protocol: tcp
mode: host Then just execute If you want to use your own env var, you can define something like graphql-engine:
image: hasura/graphql-engine
ports:
- target: 8080
published: ${HASURA_PORT} # Not hard-coded this time
protocol: tcp
mode: host and you can execute |
@rikinsk-zz How did this happen? @cjyothi is neither an org member nor collaborator of the repo, but he could unassign you?! |
GitOrigin-RevId: 8f3e9aa8a35c7610b4f2c6b98c42bd0524534803
The text was updated successfully, but these errors were encountered: