You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/07/29 05:00:39 UTC

[GitHub] [superset] sarthak opened a new pull request #15936: Add instructions for how to connect to local database from docker container

sarthak opened a new pull request #15936:
URL: https://github.com/apache/superset/pull/15936


   ### SUMMARY
   Update installation instructions to include a section on
   connecting to local db via superset running in docker container.
   
   Newcomers may have trouble in this part because it involves
   knowing about some docker internal details, as well as
   google search doesn't bring many directly useful results.
   
   If it's a commonly occurring issue among new comers,
   we may accept this commit.
   
   ### TESTING INSTRUCTIONS
   This is a documentation update, so no testing required except manual review.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] sarthak commented on a change in pull request #15936: Add instructions for how to connect to local database from docker container

Posted by GitBox <gi...@apache.org>.
sarthak commented on a change in pull request #15936:
URL: https://github.com/apache/superset/pull/15936#discussion_r679140346



##########
File path: docs/src/pages/docs/installation/index.mdx
##########
@@ -100,3 +100,11 @@ username: admin
 ```bash
 password: admin
 ```
+
+
+### 5. Connecting your local database instance to superset
+
+When running superset using `docker` or `docker-compose` it runs in its own docker container, as if the superset was running in a seperate machine entirely. Therefore attempts to connect to your local database with hostname `localhost` won't work as `localhost` refers to the docker container superset is running in, and not your actual host machine. Fortunately docker provides an easy way to access network resources in the host machine from inside a container, we will leverage this capability to connect to our local database instance. Here the instructions are for connecting to postgresql (which is running on your host machine) from superset (which is running in its docker container). Other databases may have slightly different configurations but gist would be same and boils down to 2 steps -
+
+1. Configuring the local postgresql/database instance to accept public incoming connections. By default postgresql only allows incoming connections from localhost only, but re-iterating once again, `localhosts` are different for host machine and docker container. For postgresql this involves make one-line changes to the files `postgresql.conf` and `pg_hba.conf`, you can find helpful links tailored to your OS / PG version on the web easily for this task.
+2. Instead of `localhost`, try using `host.docker.internal` or `172.18.0.1` as the host name when attempting to connect to the database. This is docker internal detail, to find the exact host name you want to use you can also do `ifconfig` or `ip addr show` and look at the ip address of `docker0` interface that must have been created by docker for you.

Review comment:
       Added.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] srinify merged pull request #15936: docs: add instructions for how to connect to local database from docker container

Posted by GitBox <gi...@apache.org>.
srinify merged pull request #15936:
URL: https://github.com/apache/superset/pull/15936


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] thathert commented on a change in pull request #15936: Add instructions for how to connect to local database from docker container

Posted by GitBox <gi...@apache.org>.
thathert commented on a change in pull request #15936:
URL: https://github.com/apache/superset/pull/15936#discussion_r679053984



##########
File path: docs/src/pages/docs/installation/index.mdx
##########
@@ -100,3 +100,11 @@ username: admin
 ```bash
 password: admin
 ```
+
+
+### 5. Connecting your local database instance to superset
+
+When running superset using `docker` or `docker-compose` it runs in its own docker container, as if the superset was running in a seperate machine entirely. Therefore attempts to connect to your local database with hostname `localhost` won't work as `localhost` refers to the docker container superset is running in, and not your actual host machine. Fortunately docker provides an easy way to access network resources in the host machine from inside a container, we will leverage this capability to connect to our local database instance. Here the instructions are for connecting to postgresql (which is running on your host machine) from superset (which is running in its docker container). Other databases may have slightly different configurations but gist would be same and boils down to 2 steps -

Review comment:
       seperate -> separate
   
   Also one style thing, it looks like Superset is capitalized in the rest of this doc. Good to stay consistent

##########
File path: docs/src/pages/docs/installation/index.mdx
##########
@@ -100,3 +100,11 @@ username: admin
 ```bash
 password: admin
 ```
+
+
+### 5. Connecting your local database instance to superset
+
+When running superset using `docker` or `docker-compose` it runs in its own docker container, as if the superset was running in a seperate machine entirely. Therefore attempts to connect to your local database with hostname `localhost` won't work as `localhost` refers to the docker container superset is running in, and not your actual host machine. Fortunately docker provides an easy way to access network resources in the host machine from inside a container, we will leverage this capability to connect to our local database instance. Here the instructions are for connecting to postgresql (which is running on your host machine) from superset (which is running in its docker container). Other databases may have slightly different configurations but gist would be same and boils down to 2 steps -
+
+1. Configuring the local postgresql/database instance to accept public incoming connections. By default postgresql only allows incoming connections from localhost only, but re-iterating once again, `localhosts` are different for host machine and docker container. For postgresql this involves make one-line changes to the files `postgresql.conf` and `pg_hba.conf`, you can find helpful links tailored to your OS / PG version on the web easily for this task.
+2. Instead of `localhost`, try using `host.docker.internal` or `172.18.0.1` as the host name when attempting to connect to the database. This is docker internal detail, to find the exact host name you want to use you can also do `ifconfig` or `ip addr show` and look at the ip address of `docker0` interface that must have been created by docker for you.

Review comment:
       You can also look at the gateway ip in the output of `docker network inspect bridge`

##########
File path: docs/src/pages/docs/installation/index.mdx
##########
@@ -100,3 +100,11 @@ username: admin
 ```bash
 password: admin
 ```
+
+
+### 5. Connecting your local database instance to superset
+
+When running superset using `docker` or `docker-compose` it runs in its own docker container, as if the superset was running in a seperate machine entirely. Therefore attempts to connect to your local database with hostname `localhost` won't work as `localhost` refers to the docker container superset is running in, and not your actual host machine. Fortunately docker provides an easy way to access network resources in the host machine from inside a container, we will leverage this capability to connect to our local database instance. Here the instructions are for connecting to postgresql (which is running on your host machine) from superset (which is running in its docker container). Other databases may have slightly different configurations but gist would be same and boils down to 2 steps -
+
+1. Configuring the local postgresql/database instance to accept public incoming connections. By default postgresql only allows incoming connections from localhost only, but re-iterating once again, `localhosts` are different for host machine and docker container. For postgresql this involves make one-line changes to the files `postgresql.conf` and `pg_hba.conf`, you can find helpful links tailored to your OS / PG version on the web easily for this task.

Review comment:
       I'd add two caveats here:
   1. This absolutely should never be done in production, and you should understand the security risks of allowing incoming connections to your local database.
   2. This normally shouldn't be necessary (at least on a mac). I didn't have to do this on my local setup because when connecting via `host.docker.internal` it looks like the connection is coming from your host network.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] srinify commented on pull request #15936: docs: add instructions for how to connect to local database from docker container

Posted by GitBox <gi...@apache.org>.
srinify commented on pull request #15936:
URL: https://github.com/apache/superset/pull/15936#issuecomment-891082256


   Hi @sarthak for future reference, your docs focused PRs need to be pre-fixed with `docs: ` for the PR linter to be happy!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] sarthak commented on a change in pull request #15936: Add instructions for how to connect to local database from docker container

Posted by GitBox <gi...@apache.org>.
sarthak commented on a change in pull request #15936:
URL: https://github.com/apache/superset/pull/15936#discussion_r679139869



##########
File path: docs/src/pages/docs/installation/index.mdx
##########
@@ -100,3 +100,11 @@ username: admin
 ```bash
 password: admin
 ```
+
+
+### 5. Connecting your local database instance to superset
+
+When running superset using `docker` or `docker-compose` it runs in its own docker container, as if the superset was running in a seperate machine entirely. Therefore attempts to connect to your local database with hostname `localhost` won't work as `localhost` refers to the docker container superset is running in, and not your actual host machine. Fortunately docker provides an easy way to access network resources in the host machine from inside a container, we will leverage this capability to connect to our local database instance. Here the instructions are for connecting to postgresql (which is running on your host machine) from superset (which is running in its docker container). Other databases may have slightly different configurations but gist would be same and boils down to 2 steps -

Review comment:
       Done.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] sarthak commented on a change in pull request #15936: Add instructions for how to connect to local database from docker container

Posted by GitBox <gi...@apache.org>.
sarthak commented on a change in pull request #15936:
URL: https://github.com/apache/superset/pull/15936#discussion_r679119583



##########
File path: docs/src/pages/docs/installation/index.mdx
##########
@@ -100,3 +100,11 @@ username: admin
 ```bash
 password: admin
 ```
+
+
+### 5. Connecting your local database instance to superset
+
+When running superset using `docker` or `docker-compose` it runs in its own docker container, as if the superset was running in a seperate machine entirely. Therefore attempts to connect to your local database with hostname `localhost` won't work as `localhost` refers to the docker container superset is running in, and not your actual host machine. Fortunately docker provides an easy way to access network resources in the host machine from inside a container, we will leverage this capability to connect to our local database instance. Here the instructions are for connecting to postgresql (which is running on your host machine) from superset (which is running in its docker container). Other databases may have slightly different configurations but gist would be same and boils down to 2 steps -
+
+1. Configuring the local postgresql/database instance to accept public incoming connections. By default postgresql only allows incoming connections from localhost only, but re-iterating once again, `localhosts` are different for host machine and docker container. For postgresql this involves make one-line changes to the files `postgresql.conf` and `pg_hba.conf`, you can find helpful links tailored to your OS / PG version on the web easily for this task.

Review comment:
       It might be an OS thing. In linux first of all `host.docker.internal` does not work, and second it was necessary when used with `172.18.0.1` as hostname. Though, agreed that this is no more than a hack. Maybe we can add a *note* here for convenience but those managing production databases should already know better!




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] thathert commented on a change in pull request #15936: Add instructions for how to connect to local database from docker container

Posted by GitBox <gi...@apache.org>.
thathert commented on a change in pull request #15936:
URL: https://github.com/apache/superset/pull/15936#discussion_r679124171



##########
File path: docs/src/pages/docs/installation/index.mdx
##########
@@ -100,3 +100,11 @@ username: admin
 ```bash
 password: admin
 ```
+
+
+### 5. Connecting your local database instance to superset
+
+When running superset using `docker` or `docker-compose` it runs in its own docker container, as if the superset was running in a seperate machine entirely. Therefore attempts to connect to your local database with hostname `localhost` won't work as `localhost` refers to the docker container superset is running in, and not your actual host machine. Fortunately docker provides an easy way to access network resources in the host machine from inside a container, we will leverage this capability to connect to our local database instance. Here the instructions are for connecting to postgresql (which is running on your host machine) from superset (which is running in its docker container). Other databases may have slightly different configurations but gist would be same and boils down to 2 steps -
+
+1. Configuring the local postgresql/database instance to accept public incoming connections. By default postgresql only allows incoming connections from localhost only, but re-iterating once again, `localhosts` are different for host machine and docker container. For postgresql this involves make one-line changes to the files `postgresql.conf` and `pg_hba.conf`, you can find helpful links tailored to your OS / PG version on the web easily for this task.

Review comment:
       Ah yes so maybe it'd be better to split this up. I think what it is, is that on mac you can do `host.docker.interal` and don't need to touch your postgresql confs. The behavior is described [here](https://docs.docker.com/docker-for-mac/networking/#there-is-no-docker0-bridge-on-macos).
   
   On other OS you don't have the magic dns entry and so you need to go through the bridge network IP which likely requires the config updates.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] srinify commented on pull request #15936: Add instructions for how to connect to local database from docker container

Posted by GitBox <gi...@apache.org>.
srinify commented on pull request #15936:
URL: https://github.com/apache/superset/pull/15936#issuecomment-891072960


   Hi @sarthak thanks for adding this! This has been on my list to add for a long time, glad you took the initiative.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org