Recall & Review
beginner
What is a database container in local development?
A database container is a lightweight, isolated environment running a database server using container technology like Docker. It helps developers run databases locally without installing them directly on their machines.
Click to reveal answer
beginner
Why use database containers instead of installing databases directly?
Database containers are easy to start, stop, and reset. They avoid conflicts with other software and keep your system clean. You can also share the exact database setup with your team.
Click to reveal answer
intermediate
Which Docker command starts a PostgreSQL database container named 'mydb' with password 'mypassword'?
docker run --name mydb -e POSTGRES_PASSWORD=mypassword -p 5432:5432 -d postgres
Click to reveal answer
intermediate
How do you persist data in a database container so it is not lost when the container stops?
Use Docker volumes to store database files outside the container. For example, add '-v mydbdata:/var/lib/postgresql/data' to the docker run command to keep data safe.
Click to reveal answer
beginner
What port mapping is needed to access a MySQL container running on port 3306 from your local machine?
You map the container's port 3306 to a local port, usually 3306, using '-p 3306:3306' in the docker run command. This lets your local apps connect to the database container.
Click to reveal answer
What is the main benefit of using a database container for local development?
✗ Incorrect
Database containers isolate the database from your system, avoiding conflicts and making setup easier.
Which Docker option sets environment variables like database passwords?
✗ Incorrect
The '-e' option sets environment variables inside the container.
How do you keep database data safe when restarting a container?
✗ Incorrect
Docker volumes keep data outside the container so it persists across restarts.
What does the '-p 5432:5432' option do in a Docker run command for PostgreSQL?
✗ Incorrect
The '-p' option maps ports between your machine and the container.
Which command starts a MySQL container named 'mysql-dev' with root password 'rootpass'?
✗ Incorrect
This command runs a MySQL container with the root password set and port mapped.
Explain how to set up a PostgreSQL database container for local development including data persistence.
Think about the options -e, -p, and -v in docker run.
You got /4 concepts.
Describe the advantages of using database containers over installing databases directly on your computer.
Consider how containers keep things separate and easy to manage.
You got /4 concepts.