Skip to content

Commit f751485

Browse files
feat: module 2 for 2026 cohort (#749)
* feat: pin docker image versions, add 2025 cohort * feat: cut dbt, add AI Workflows & AI Agents section * fix: simplify docker set up * fix: pg db config * fix: amend pg db name * feat: reduce the scope * fix: update structure for 2026 * simplify docker compose set up * fix: postgres volume * fix: install instructions * make module 1 pg work with module 2 * make sure docker compose matches readme * add more introductory stages * flesh out readme * 2.2 details * fix: headers * 2.1 complete * fix heading * feat: 2.2.1 video * Add 2.2.2 to 2.3.1 * fix: placeholders for videos --------- Co-authored-by: Will Russell <[email protected]> Co-authored-by: Will Russell <[email protected]>
1 parent 536df6d commit f751485

30 files changed

+2340
-482
lines changed

01-docker-terraform/2_docker_sql/README.md

Lines changed: 16 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -17,61 +17,21 @@ wget https://github.com/DataTalksClub/nyc-tlc-data/releases/download/yellow/yell
1717
1818
### Running Postgres with Docker
1919

20-
#### Windows
21-
22-
Running Postgres on Windows (note the full path)
20+
Running Postgres on Windows, macOS and Linux
2321

2422
```bash
2523
docker run -it \
2624
-e POSTGRES_USER="root" \
2725
-e POSTGRES_PASSWORD="root" \
2826
-e POSTGRES_DB="ny_taxi" \
29-
-v c:/Users/alexe/git/data-engineering-zoomcamp/week_1_basics_n_setup/2_docker_sql/ny_taxi_postgres_data:/var/lib/postgresql/data \
30-
-p 5432:5432 \
31-
postgres:13
32-
```
33-
34-
If you have the following error:
35-
36-
```
37-
docker run -it \
38-
-e POSTGRES_USER="root" \
39-
-e POSTGRES_PASSWORD="root" \
40-
-e POSTGRES_DB="ny_taxi" \
41-
-v e:/zoomcamp/data_engineer/week_1_fundamentals/2_docker_sql/ny_taxi_postgres_data:/var/lib/postgresql/data \
27+
-v ny_taxi_postgres_data:/var/lib/postgresql \
4228
-p 5432:5432 \
43-
postgres:13
44-
45-
docker: Error response from daemon: invalid mode: \Program Files\Git\var\lib\postgresql\data.
46-
See 'docker run --help'.
47-
```
48-
49-
Change the mounting path. Replace it with the following:
50-
51-
```
52-
-v /e/zoomcamp/...:/var/lib/postgresql/data
53-
```
54-
55-
#### Linux and MacOS
56-
57-
58-
```bash
59-
docker run -it \
60-
-e POSTGRES_USER="root" \
61-
-e POSTGRES_PASSWORD="root" \
62-
-e POSTGRES_DB="ny_taxi" \
63-
-v $(pwd)/ny_taxi_postgres_data:/var/lib/postgresql/data \
64-
-p 5432:5432 \
65-
postgres:13
29+
postgres:18
6630
```
6731

6832
If you see that `ny_taxi_postgres_data` is empty after running
6933
the container, try these:
7034

71-
* Deleting the folder and running Docker again (Docker will re-create the folder)
72-
* Adjust the permissions of the folder by running `sudo chmod a+rwx ny_taxi_postgres_data`
73-
74-
7535
### CLI for Postgres
7636

7737
Installing `pgcli`
@@ -143,7 +103,7 @@ Running pgAdmin
143103
docker run -it \
144104
-e PGADMIN_DEFAULT_EMAIL="[email protected]" \
145105
-e PGADMIN_DEFAULT_PASSWORD="root" \
146-
-p 8080:80 \
106+
-p 8085:80 \
147107
dpage/pgadmin4
148108
```
149109

@@ -162,11 +122,11 @@ docker run -it \
162122
-e POSTGRES_USER="root" \
163123
-e POSTGRES_PASSWORD="root" \
164124
-e POSTGRES_DB="ny_taxi" \
165-
-v c:/Users/alexe/git/data-engineering-zoomcamp/week_1_basics_n_setup/2_docker_sql/ny_taxi_postgres_data:/var/lib/postgresql/data \
125+
-v ny_taxi_postgres_data:/var/lib/postgresql \
166126
-p 5432:5432 \
167127
--network=pg-network \
168-
--name pg-database \
169-
postgres:13
128+
--name pgdatabase \
129+
postgres:18
170130
```
171131

172132
Run pgAdmin
@@ -175,14 +135,14 @@ Run pgAdmin
175135
docker run -it \
176136
-e PGADMIN_DEFAULT_EMAIL="[email protected]" \
177137
-e PGADMIN_DEFAULT_PASSWORD="root" \
178-
-p 8080:80 \
138+
-p 8085:80 \
179139
--network=pg-network \
180140
--name pgadmin-2 \
181141
dpage/pgadmin4
182142
```
183143

184144

185-
### Data ingestion
145+
### Data Ingestion
186146

187147
Running locally
188148

@@ -205,22 +165,6 @@ Build the image
205165
docker build -t taxi_ingest:v001 .
206166
```
207167

208-
On Linux you may have a problem building it:
209-
210-
```
211-
error checking context: 'can't stat '/home/name/data_engineering/ny_taxi_postgres_data''.
212-
```
213-
214-
You can solve it with `.dockerignore`:
215-
216-
* Create a folder `data`
217-
* Move `ny_taxi_postgres_data` to `data` (you might need to use `sudo` for that)
218-
* Map `-v $(pwd)/data/ny_taxi_postgres_data:/var/lib/postgresql/data`
219-
* Create a file `.dockerignore` and add `data` there
220-
* Check [this video](https://www.youtube.com/watch?v=tOr4hTsHOzU&list=PL3MmuxUbc_hJed7dXYoJw8DoCuVHhGEQb) (the middle) for more details
221-
222-
223-
224168
Run the script with Docker
225169

226170
```bash
@@ -231,47 +175,41 @@ docker run -it \
231175
taxi_ingest:v001 \
232176
--user=root \
233177
--password=root \
234-
--host=pg-database \
178+
--host=pgdatabase \
235179
--port=5432 \
236180
--db=ny_taxi \
237181
--table_name=yellow_taxi_trips \
238182
--url=${URL}
239183
```
240184

241-
### Docker-Compose
185+
### Docker Compose
242186

243187
Run it:
244188

245189
```bash
246-
docker-compose up
190+
docker compose up
247191
```
248192

249193
Run in detached mode:
250194

251195
```bash
252-
docker-compose up -d
196+
docker compose up -d
253197
```
254198

255199
Shutting it down:
256200

257201
```bash
258-
docker-compose down
259-
```
260-
261-
Note: to make pgAdmin configuration persistent, create a folder `data_pgadmin`. Change its permission via
262-
263-
```bash
264-
sudo chown 5050:5050 data_pgadmin
202+
docker compose down
265203
```
266204

267-
and mount it to the `/var/lib/pgadmin` folder:
205+
Add a docker volume to the `pgadmin` container:
268206

269207
```yaml
270208
services:
271209
pgadmin:
272210
image: dpage/pgadmin4
273211
volumes:
274-
- ./data_pgadmin:/var/lib/pgadmin
212+
- data_pgadmin:/var/lib/pgadmin
275213
...
276214
```
277215

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
volumes:
2+
ny_taxi_postgres_data:
3+
driver: local
4+
15
services:
26
pgdatabase:
3-
image: postgres:13
7+
image: postgres:18
48
environment:
59
- POSTGRES_USER=root
610
- POSTGRES_PASSWORD=root
711
- POSTGRES_DB=ny_taxi
812
volumes:
9-
- "./ny_taxi_postgres_data:/var/lib/postgresql/data:rw"
13+
- ny_taxi_postgres_data:/var/lib/postgresql
1014
ports:
1115
- "5432:5432"
1216
pgadmin:
@@ -15,5 +19,5 @@ services:
1519
1620
- PGADMIN_DEFAULT_PASSWORD=root
1721
ports:
18-
- "8080:80"
22+
- "8085:80"
1923

0 commit comments

Comments
 (0)