Create a Postgres Container with Northwind and Adventureworks built-in
Table of Contents
References
Steps
First, clone the repository Github - Adventureworks for postgres
Download the AdventureWorks OLTP script into this repository:
curl -L -o adventureWorks2022.zip https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorks-oltp-install-script.zip
Update the Dockerfile to use adventureWorks2022
FROM postgres:15
RUN apt-get update
RUN apt-get -y install unzip ruby dos2unix
RUN mkdir /data
COPY install.sql /data/
COPY update_csvs.rb /data/
COPY adventureWorks2022.zip /data/
RUN cd /data && \
unzip adventureWorks2022.zip && \
rm adventureWorks2022.zip && \
ruby update_csvs.rb && \
rm update_csvs.rb
COPY install.sh /docker-entrypoint-initdb.d/
WORKDIR /data/
RUN dos2unix /docker-entrypoint-initdb.d/*.sh
Build the docker file with a image name of postgres-15.
docker build -t postgres-15 .
Update the Docker Compose file and give it a container name and the newly created image name.
services:
db:
image: postgres-15
container_name: postgres1
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- '5432:5432'
Execute docker compose up
Download the Northwind sql for postgres file.
Connect to the postgres instance using pgAdmin.
Create a new database Northwind and execute the script.