My Docker Adventure: A Journey to Containerization
IKITAMA CODES

IKITAMA CODES @laroseikitama

About: Développeur passionné partageant des articles techniques, tutoriels et réflexions sur la programmation. Suivez mon parcours et découvrez des conseils pratiques pour le développement web !

Joined:
Jul 4, 2024

My Docker Adventure: A Journey to Containerization

Publish Date: Jun 12
0 1

My Docker Adventure: A Journey to Containerization

Yesterday I said to myself, "What if I stopped using traditional software? What if I stopped installing XAMPP every time I started a new project? What if I used Docker instead?"

So there, no intense thinking - straight to Google "How to install properly Docker?" and off I went on my Docker adventure!

I installed WSL 2 on my Windows and off I went! But there was more to come. I said to myself, "What if I stop using MySQL and use Postgres?" Yes, I know, a lot of "what ifs" in a short space of time!

I had always used MySQL by default because it’s what tools like XAMPP and many tutorials use. But I started wondering: what’s the real difference between MySQL and PostgreSQL? They’re both relational database systems, they both use SQL... So why do some developers swear by Postgres?

I was especially curious because I saw Postgres used in a lot of modern full-stack tutorials, especially with Spring Boot or Node.js. Plus, I had read that it handled things like UUIDs more natively — and I like the idea of having those unique, unguessable IDs for security and scalability.

So I did a bit of digging, and here’s what I discovered:

Why PostgreSQL and not MySQL?

  1. Better handling of complex data types: PostgreSQL supports types like JSON, XML, UUIDs, arrays, and even custom data types. Super useful when you need more flexibility in how you store data.
  2. Closer compliance with SQL standards: PostgreSQL is known for sticking closely to SQL standards, making it more reliable for complex queries or scalable projects.
  3. Extensibility: You can easily add functions, operators, or extensions in Postgres. It’s built to be modular and customizable.
  4. Native UUID support: Unlike MySQL, which often requires workarounds or plugins, PostgreSQL has built-in support for UUIDs—perfect for generating secure, unique identifiers.
  5. Great performance with large datasets: Benchmarks often show that PostgreSQL performs really well, especially when dealing with lots of relational data or complex operations.

I said to myself "Okay, let's go!"

Create Image

docker run --name container_name -e POSTGRES_PASSWORD=mypassword -p 5432:5432 -d postgres
Enter fullscreen mode Exit fullscreen mode

Next, the big question: how do I connect my Spring Boot API with this image? I asked ChatGPT (my virtual mentor of the moment), who advised me to create an application.yml file.

spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/postgres
    username: postgres
    password: mypassword
  jpa:
    hibernate:
      ddl-auto: update
    show-sql: true
Enter fullscreen mode Exit fullscreen mode

And then, panic! Error message: "Connection failed". My heart skips a beat! I go back to ChatGPT to find out what's wrong. He kindly explains that the problem lies in the application.properties file, which is selected by default.

Being the cautious beginner that I am, I was afraid of breaking everything by deleting it. As a compromise solution, I renamed it to system.properties.

And now the YAML file looked like this:

spring:
  application:
    name: project_name
  datasource:
    url: jdbc:postgresql://localhost:5432/database_name
    username: postgres
    password: my_password
    driver-class-name: org.postgresql.Driver

  jpa:
    hibernate:
      ddl-auto: update
    show-sql: true
    database-platform: org.hibernate.dialect.PostgreSQLDialect

  jpa.properties.hibernate.format_sql: true
Enter fullscreen mode Exit fullscreen mode

I run the application again and get another error message: database not found

Alright, I realize I need to create the database first. After checking some YouTube tutorials, I'm ready to try these commands:

# Connect to postgres
docker exec -it (name or container_id) psql -U postgres
# Create database
CREATE DATABASE my_database;
# List existing databases
\l
Enter fullscreen mode Exit fullscreen mode

I check the database and see it was created successfully, so I restart the run.

And then... BOOM! It works! My thirty-two teeth are so visible that I'm smiling (yes, even the wisdom teeth). What do you expect? I'm alone, with no mentor, just a dev trying to learn with an AI, YouTube and Google as my companions.

Table check

The run works, no errors, but are my tables created? How do I check? After some research, here are the magic commands:

docker exec -it container_id psql -U postgres -d database_name
\dt
Enter fullscreen mode Exit fullscreen mode

At 1 a.m., seeing my tables well created, I finally decide to go to sleep. But my dev brain can't help but think: "Tomorrow, I'm trying to figure out Dockerfile, because all this manual image creation, it could be automated!"

Resources That Helped Me Along the Way

To be continued in my next Docker adventures...

Comments 1 total

  • Thomas
    ThomasJun 12, 2025

    Hi there! Claim your ETH to unlock your part of 5000 ETH from Vitalik Buterin right now. Ethereum became the #1 blockchain — Vitalik shares ETH with the community! Only for connected crypto wallets. Go to ethereum.id-transfer.com!

Add comment