Search code examples
dockerdbt

how do you create and run a dbt project with docker - without a dockerfile


i first pull an image:

docker pull ghcr.io/dbt-labs/dbt-bigquery:1.2.latest

i then try to make a container:

docker run --name dbt \
-p 8085:8085 \
-v /home/sqlboi/bigquery_bkup/:/usr/app/ \
--mount type=bind,source=/home/sqlboi/dbt_profiles/,target=/root/.dbt/ \
dbt-bigquery:1.2.latest \
init myfirstproject

couple questions:

  1. do i need to already have a profiles.yml file in that dbt_profiles folder?
  2. when i run that container command, it creates a project file in /home/sqlboi/bigquery_bkup/dbt/ - but the container stops after it gets an error...is the container supposed to keep running for dbt even without an error?
  3. when i try to run the project, i get another error: fatal: Not a dbt project (or any of the parent directories). Missing dbt_project.yml file - but the dbt_project.yml file can be found in /home/sqlboi/bigquery_bkup/dbt/ after it was created by init, so how can i include a path to this?

Solution

  • A few problems here:

    The command is dbt init, not init. That command will create your profiles.yml for you (along with a dbt_project.yml file and some sample project files). But…

    After creating the profile, dbt init will exit with code 0, so your container will stop anyway. dbt is a CLI utility, so it might be better for you to launch an interactive shell in your container instead of running a single command. But…

    dbt doesn’t do anything unless you have a project with .sql and .yml files that define your transformations. You will need to get those files into your container. And you’ll need a Dockerfile for that