blob: 0023774b8690e48177239c1dbaf688b9d9ed83b3 [file] [log] [blame]
"use strict";(self.webpackChunkdocs_v_2=self.webpackChunkdocs_v_2||[]).push([[5164],{95788:(e,n,o)=>{o.d(n,{Iu:()=>c,yg:()=>g});var t=o(11504);function a(e,n,o){return n in e?Object.defineProperty(e,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[n]=o,e}function r(e,n){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),o.push.apply(o,t)}return o}function i(e){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?r(Object(o),!0).forEach((function(n){a(e,n,o[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):r(Object(o)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))}))}return e}function s(e,n){if(null==e)return{};var o,t,a=function(e,n){if(null==e)return{};var o,t,a={},r=Object.keys(e);for(t=0;t<r.length;t++)o=r[t],n.indexOf(o)>=0||(a[o]=e[o]);return a}(e,n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(t=0;t<r.length;t++)o=r[t],n.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(a[o]=e[o])}return a}var l=t.createContext({}),p=function(e){var n=t.useContext(l),o=n;return e&&(o="function"==typeof e?e(n):i(i({},n),e)),o},c=function(e){var n=p(e.components);return t.createElement(l.Provider,{value:n},e.children)},d="mdxType",u={inlineCode:"code",wrapper:function(e){var n=e.children;return t.createElement(t.Fragment,{},n)}},m=t.forwardRef((function(e,n){var o=e.components,a=e.mdxType,r=e.originalType,l=e.parentName,c=s(e,["components","mdxType","originalType","parentName"]),d=p(o),m=a,g=d["".concat(l,".").concat(m)]||d[m]||u[m]||r;return o?t.createElement(g,i(i({ref:n},c),{},{components:o})):t.createElement(g,i({ref:n},c))}));function g(e,n){var o=arguments,a=n&&n.mdxType;if("string"==typeof e||a){var r=o.length,i=new Array(r);i[0]=m;var s={};for(var l in n)hasOwnProperty.call(n,l)&&(s[l]=n[l]);s.originalType=e,s[d]="string"==typeof e?e:a,i[1]=s;for(var p=2;p<r;p++)i[p]=o[p];return t.createElement.apply(null,i)}return t.createElement.apply(null,o)}m.displayName="MDXCreateElement"},30612:(e,n,o)=>{o.r(n),o.d(n,{assets:()=>l,contentTitle:()=>i,default:()=>u,frontMatter:()=>r,metadata:()=>s,toc:()=>p});var t=o(45072),a=(o(11504),o(95788));const r={title:"Installing Locally Using Docker Compose",hide_title:!0,sidebar_position:1,version:1},i=void 0,s={unversionedId:"installation/installing-superset-using-docker-compose",id:"installation/installing-superset-using-docker-compose",title:"Installing Locally Using Docker Compose",description:"Installing Superset Locally Using Docker Compose",source:"@site/docs/installation/installing-superset-using-docker-compose.mdx",sourceDirName:"installation",slug:"/installation/installing-superset-using-docker-compose",permalink:"/docs/installation/installing-superset-using-docker-compose",draft:!1,editUrl:"https://github.com/apache/superset/edit/master/docs/docs/installation/installing-superset-using-docker-compose.mdx",tags:[],version:"current",sidebarPosition:1,frontMatter:{title:"Installing Locally Using Docker Compose",hide_title:!0,sidebar_position:1,version:1},sidebar:"tutorialSidebar",previous:{title:"Quickstart",permalink:"/docs/quickstart"},next:{title:"Installing from PyPI",permalink:"/docs/installation/installing-superset-from-pypi"}},l={},p=[{value:"Installing Superset Locally Using Docker Compose",id:"installing-superset-locally-using-docker-compose",level:2},{value:"1. Install a Docker Engine and Docker Compose",id:"1-install-a-docker-engine-and-docker-compose",level:3},{value:"2. Clone Superset&#39;s GitHub repository",id:"2-clone-supersets-github-repository",level:3},{value:"3. Launch Superset Through Docker Compose",id:"3-launch-superset-through-docker-compose",level:3},{value:"Configuring Docker Compose",id:"configuring-docker-compose",level:4},{value:"4. Log in to Superset",id:"4-log-in-to-superset",level:3},{value:"5. Connecting Superset to your local database instance",id:"5-connecting-superset-to-your-local-database-instance",level:3}],c={toc:p},d="wrapper";function u(e){let{components:n,...o}=e;return(0,a.yg)(d,(0,t.c)({},c,o,{components:n,mdxType:"MDXLayout"}),(0,a.yg)("h2",{id:"installing-superset-locally-using-docker-compose"},"Installing Superset Locally Using Docker Compose"),(0,a.yg)("p",null,"The fastest way to try Superset locally is using Docker and Docker Compose on a Linux or Mac OSX\ncomputer. Superset does not have official support for Windows, so we have provided a VM workaround\nbelow."),(0,a.yg)("h3",{id:"1-install-a-docker-engine-and-docker-compose"},"1. Install a Docker Engine and Docker Compose"),(0,a.yg)("p",null,(0,a.yg)("strong",{parentName:"p"},"Mac OSX")),(0,a.yg)("p",null,(0,a.yg)("a",{parentName:"p",href:"https://docs.docker.com/docker-for-mac/install/"},"Install Docker for Mac"),", which includes the Docker\nengine and a recent version of ",(0,a.yg)("inlineCode",{parentName:"p"},"docker compose")," out of the box."),(0,a.yg)("p",null,'Once you have Docker for Mac installed, open up the preferences pane for Docker, go to the\n"Resources" section and increase the allocated memory to 6GB. With only the 2GB of RAM allocated by\ndefault, Superset will fail to start.'),(0,a.yg)("p",null,(0,a.yg)("strong",{parentName:"p"},"Linux")),(0,a.yg)("p",null,(0,a.yg)("a",{parentName:"p",href:"https://docs.docker.com/engine/install/"},"Install Docker on Linux")," by following Docker\u2019s\ninstructions for whichever flavor of Linux suits you. Because ",(0,a.yg)("inlineCode",{parentName:"p"},"docker compose")," is not installed as\npart of the base Docker installation on Linux, once you have a working engine, follow the\n",(0,a.yg)("a",{parentName:"p",href:"https://docs.docker.com/compose/install/"},"docker compose installation instructions")," for Linux."),(0,a.yg)("p",null,(0,a.yg)("strong",{parentName:"p"},"Windows")),(0,a.yg)("p",null,"Superset is not officially supported on Windows unfortunately. One option for Windows users to\ntry out Superset locally is to install an Ubuntu Desktop VM via\n",(0,a.yg)("a",{parentName:"p",href:"https://www.virtualbox.org/"},"VirtualBox")," and proceed with the Docker on Linux instructions inside\nof that VM. We recommend assigning at least 8GB of RAM to the virtual machine as well as\nprovisioning a hard drive of at least 40GB, so that there will be enough space for both the OS and\nall of the required dependencies. Docker Desktop ",(0,a.yg)("a",{parentName:"p",href:"https://docs.docker.com/docker-for-windows/wsl/"},"recently added support for Windows Subsystem for Linux (WSL) 2"),", which may be another option."),(0,a.yg)("h3",{id:"2-clone-supersets-github-repository"},"2. Clone Superset's GitHub repository"),(0,a.yg)("p",null,(0,a.yg)("a",{parentName:"p",href:"https://github.com/apache/superset"},"Clone Superset's repo")," in your terminal with the\nfollowing command:"),(0,a.yg)("pre",null,(0,a.yg)("code",{parentName:"pre",className:"language-bash"},"git clone https://github.com/apache/superset.git\n")),(0,a.yg)("p",null,"Once that command completes successfully, you should see a new ",(0,a.yg)("inlineCode",{parentName:"p"},"superset")," folder in your\ncurrent directory."),(0,a.yg)("h3",{id:"3-launch-superset-through-docker-compose"},"3. Launch Superset Through Docker Compose"),(0,a.yg)("p",null,"Navigate to the folder you created in step 1:"),(0,a.yg)("pre",null,(0,a.yg)("code",{parentName:"pre",className:"language-bash"},"cd superset\n")),(0,a.yg)("p",null,"When working on master branch, run the following commands to run ",(0,a.yg)("inlineCode",{parentName:"p"},"development")," mode using ",(0,a.yg)("inlineCode",{parentName:"p"},"docker compose"),":"),(0,a.yg)("pre",null,(0,a.yg)("code",{parentName:"pre",className:"language-bash"},"docker compose up\n")),(0,a.yg)("admonition",{type:"tip"},(0,a.yg)("p",{parentName:"admonition"},"When running in development mode the ",(0,a.yg)("inlineCode",{parentName:"p"},"superset-node")," container needs to finish building assets in order for the UI to render properly. If you would just like to try out Superset without making any code changes follow the steps documented for ",(0,a.yg)("inlineCode",{parentName:"p"},"production")," or a specific version below.")),(0,a.yg)("p",null,"When working on master branch, run the following commands to run ",(0,a.yg)("inlineCode",{parentName:"p"},"production")," mode using ",(0,a.yg)("inlineCode",{parentName:"p"},"docker compose"),":"),(0,a.yg)("pre",null,(0,a.yg)("code",{parentName:"pre",className:"language-bash"},"docker compose -f docker-compose-non-dev.yml pull\ndocker compose -f docker-compose-non-dev.yml up\n")),(0,a.yg)("p",null,"Alternatively, you can also run a specific version of Superset by first checking out\nthe branch/tag, and then starting ",(0,a.yg)("inlineCode",{parentName:"p"},"docker compose")," with the ",(0,a.yg)("inlineCode",{parentName:"p"},"TAG")," variable.\nFor example, to run the 3.0.0 version, run the following commands on Linux-based systems:"),(0,a.yg)("pre",null,(0,a.yg)("code",{parentName:"pre",className:"language-bash"},"git checkout 3.0.0\nTAG=3.0.0 docker compose -f docker-compose-non-dev.yml pull\nTAG=3.0.0 docker compose -f docker-compose-non-dev.yml up\n")),(0,a.yg)("p",null,"If you are using Docker Desktop for Windows then run the following commands:"),(0,a.yg)("pre",null,(0,a.yg)("code",{parentName:"pre",className:"language-bash"},"git checkout 3.0.0\nset TAG=3.0.0\ndocker compose -f docker-compose-non-dev.yml pull\ndocker compose -f docker-compose-non-dev.yml up\n")),(0,a.yg)("admonition",{type:"tip"},(0,a.yg)("p",{parentName:"admonition"},"Note that some configuration is mandatory for production instances of Superset. In particular, Superset will not start without a user-specified value of ",(0,a.yg)("inlineCode",{parentName:"p"},"SECRET_KEY")," in a Superset config file or ",(0,a.yg)("inlineCode",{parentName:"p"},"SUPERSET_SECRET_KEY")," as an ",(0,a.yg)("a",{parentName:"p",href:"https://github.com/apache/superset/blob/master/docker/.env-non-dev"},"environment variable"),". Please see ",(0,a.yg)("a",{parentName:"p",href:"/docs/installation/configuring-superset/"},"Configuring Superset")," for more details.")),(0,a.yg)("admonition",{type:"caution"},(0,a.yg)("p",{parentName:"admonition"},"All of the content belonging to a Superset instance - charts, dashboards, users, etc. - is stored in its metadata database. In production, this database should be backed up.\nThe default installation with docker compose will store that data in a PostgreSQL database contained in a Docker ",(0,a.yg)("a",{parentName:"p",href:"https://docs.docker.com/storage/volumes/"},"volume"),",\nwhich is not backed up. To avoid risking data loss, either use a managed database for your metadata (recommended) or perform your own regular backups by extracting\nand storing the contents of the default PostgreSQL database from its volume (here's an\n",(0,a.yg)("a",{parentName:"p",href:"https://stackoverflow.com/questions/24718706/backup-restore-a-dockerized-postgresql-database"},"example of how to dump and restore"),").")),(0,a.yg)("p",null,"You should see a wall of logging output from the containers being launched on your machine. Once\nthis output slows, you should have a running instance of Superset on your local machine! To\navoid the wall of text on future runs, add the ",(0,a.yg)("inlineCode",{parentName:"p"},"-d")," option to the end of the ",(0,a.yg)("inlineCode",{parentName:"p"},"docker compose up")," command."),(0,a.yg)("h4",{id:"configuring-docker-compose"},"Configuring Docker Compose"),(0,a.yg)("p",null,"The following is for users who want to configure how Superset runs in Docker Compose; otherwise, you can skip to the next section."),(0,a.yg)("p",null,"You can install additional python packages and apply config overrides by following the steps mentioned in ",(0,a.yg)("a",{parentName:"p",href:"https://github.com/apache/superset/tree/master/docker#configuration"},"docker/README.md")),(0,a.yg)("p",null,"You can configure the Docker Compose environment variables for dev and non-dev mode with ",(0,a.yg)("inlineCode",{parentName:"p"},"docker/.env")," and ",(0,a.yg)("inlineCode",{parentName:"p"},"docker/.env-non-dev")," respectively. These environment files set the environment for most containers in the Docker Compose setup, and some variables affect multiple containers and others only single ones."),(0,a.yg)("p",null,"One important variable is ",(0,a.yg)("inlineCode",{parentName:"p"},"SUPERSET_LOAD_EXAMPLES")," which determines whether the ",(0,a.yg)("inlineCode",{parentName:"p"},"superset_init")," container will populate example data and visualizations into the metadata database. These examples are helpful for learning and testing out Superset but unnecessary for experienced users and production deployments. The loading process can sometimes take a few minutes and a good amount of CPU, so you may want to disable it on a resource-constrained device."),(0,a.yg)("admonition",{type:"note"},(0,a.yg)("p",{parentName:"admonition"},"Users often want to connect to other databases from Superset. Currently, the easiest way to do this is to modify the ",(0,a.yg)("inlineCode",{parentName:"p"},"docker-compose-non-dev.yml")," file and add your database as a service that the other services depend on (via ",(0,a.yg)("inlineCode",{parentName:"p"},"x-superset-depends-on"),"). Others have attempted to set ",(0,a.yg)("inlineCode",{parentName:"p"},"network_mode: host")," on the Superset services, but these generally break the installation, because the configuration requires use of the Docker Compose DNS resolver for the service names. If you have a good solution for this, let us know!")),(0,a.yg)("admonition",{type:"note"},(0,a.yg)("p",{parentName:"admonition"},"Superset uses ",(0,a.yg)("a",{parentName:"p",href:"https://about.scarf.sh/scarf-gateway"},"Scarf Gateway")," to collect telemetry data. Knowing the installation counts for different Superset versions informs the project's decisions about patching and long-term support. Scarf purges personally identifiable information (PII) and provides only aggregated statistics."),(0,a.yg)("p",{parentName:"admonition"},"To opt-out of this data collection for packages downloaded through the Scarf Gateway by your docker compose based installation, edit the ",(0,a.yg)("inlineCode",{parentName:"p"},"x-superset-image:")," line in your ",(0,a.yg)("inlineCode",{parentName:"p"},"docker-compose.yml")," and ",(0,a.yg)("inlineCode",{parentName:"p"},"docker-compose-non-dev.yml")," files, replacing ",(0,a.yg)("inlineCode",{parentName:"p"},"apachesuperset.docker.scarf.sh/apache/superset")," with ",(0,a.yg)("inlineCode",{parentName:"p"},"apache/superset")," to pull the image directly from Docker Hub."),(0,a.yg)("p",{parentName:"admonition"},"To disable the Scarf telemetry pixel, set the ",(0,a.yg)("inlineCode",{parentName:"p"},"SCARF_ANALYTICS")," environment variable to ",(0,a.yg)("inlineCode",{parentName:"p"},"False")," in your terminal and/or in your ",(0,a.yg)("inlineCode",{parentName:"p"},"docker/.env")," and ",(0,a.yg)("inlineCode",{parentName:"p"},"docker/.env-non-dev")," files.")),(0,a.yg)("h3",{id:"4-log-in-to-superset"},"4. Log in to Superset"),(0,a.yg)("p",null,"Your local Superset instance also includes a Postgres server to store your data and is already\npre-loaded with some example datasets that ship with Superset. You can access Superset now via your\nweb browser by visiting ",(0,a.yg)("inlineCode",{parentName:"p"},"http://localhost:8088"),". Note that many browsers now default to ",(0,a.yg)("inlineCode",{parentName:"p"},"https")," - if\nyours is one of them, please make sure it uses ",(0,a.yg)("inlineCode",{parentName:"p"},"http"),"."),(0,a.yg)("p",null,"Log in with the default username and password:"),(0,a.yg)("pre",null,(0,a.yg)("code",{parentName:"pre",className:"language-bash"},"username: admin\n")),(0,a.yg)("pre",null,(0,a.yg)("code",{parentName:"pre",className:"language-bash"},"password: admin\n")),(0,a.yg)("h3",{id:"5-connecting-superset-to-your-local-database-instance"},"5. Connecting Superset to your local database instance"),(0,a.yg)("p",null,"When running Superset using ",(0,a.yg)("inlineCode",{parentName:"p"},"docker")," or ",(0,a.yg)("inlineCode",{parentName:"p"},"docker compose")," it runs in its own docker container, as if the Superset was running in a separate machine entirely. Therefore attempts to connect to your local database with the hostname ",(0,a.yg)("inlineCode",{parentName:"p"},"localhost")," won't work as ",(0,a.yg)("inlineCode",{parentName:"p"},"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, and we will leverage this capability to connect to our local database instance."),(0,a.yg)("p",null,"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 -"),(0,a.yg)("ol",null,(0,a.yg)("li",{parentName:"ol"},(0,a.yg)("strong",{parentName:"li"},"(Mac users may skip this step)")," Configuring the local postgresql/database instance to accept public incoming connections. By default, postgresql only allows incoming connections from ",(0,a.yg)("inlineCode",{parentName:"li"},"localhost")," and under Docker, unless you use ",(0,a.yg)("inlineCode",{parentName:"li"},"--network=host"),", ",(0,a.yg)("inlineCode",{parentName:"li"},"localhost")," will refer to different endpoints on the host machine and in a docker container respectively. Allowing postgresql to accept connections from the Docker involves making one-line changes to the files ",(0,a.yg)("inlineCode",{parentName:"li"},"postgresql.conf")," and ",(0,a.yg)("inlineCode",{parentName:"li"},"pg_hba.conf"),"; you can find helpful links tailored to your OS / PG version on the web easily for this task. For Docker it suffices to only whitelist IPs ",(0,a.yg)("inlineCode",{parentName:"li"},"172.0.0.0/8")," instead of ",(0,a.yg)("inlineCode",{parentName:"li"},"*"),", but in any case you are ",(0,a.yg)("em",{parentName:"li"},"warned")," that doing this in a production database ",(0,a.yg)("em",{parentName:"li"},"may")," have disastrous consequences as you are opening your database to the public internet."),(0,a.yg)("li",{parentName:"ol"},"Instead of ",(0,a.yg)("inlineCode",{parentName:"li"},"localhost"),", try using ",(0,a.yg)("inlineCode",{parentName:"li"},"host.docker.internal")," (Mac users, Ubuntu) or ",(0,a.yg)("inlineCode",{parentName:"li"},"172.18.0.1")," (Linux users) as the hostname when attempting to connect to the database. This is a Docker internal detail -- what is happening is that, in Mac systems, Docker Desktop creates a dns entry for the hostname ",(0,a.yg)("inlineCode",{parentName:"li"},"host.docker.internal")," which resolves to the correct address for the host machine, whereas in Linux this is not the case (at least by default). If neither of these 2 hostnames work then you may want to find the exact hostname you want to use, for that you can do ",(0,a.yg)("inlineCode",{parentName:"li"},"ifconfig")," or ",(0,a.yg)("inlineCode",{parentName:"li"},"ip addr show")," and look at the IP address of ",(0,a.yg)("inlineCode",{parentName:"li"},"docker0")," interface that must have been created by Docker for you. Alternately if you don't even see the ",(0,a.yg)("inlineCode",{parentName:"li"},"docker0")," interface try (if needed with sudo) ",(0,a.yg)("inlineCode",{parentName:"li"},"docker network inspect bridge")," and see if there is an entry for ",(0,a.yg)("inlineCode",{parentName:"li"},'"Gateway"')," and note the IP address.")))}u.isMDXComponent=!0}}]);