0
0
Dockerdevops~5 mins

Database containers for local development in Docker - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AIt removes the need for a database password
BIt makes the database run faster than on a server
CIt isolates the database environment from your system
DIt automatically backs up your data to the cloud
Which Docker option sets environment variables like database passwords?
A-e
B-p
C-v
D--name
How do you keep database data safe when restarting a container?
AData is always safe inside the container
BRestart the container with the --reset flag
CUse the --no-delete option
DUse Docker volumes to store data outside the container
What does the '-p 5432:5432' option do in a Docker run command for PostgreSQL?
ALimits the container memory to 5432MB
BMaps local port 5432 to container port 5432
CNames the container 5432
DSets the password to 5432
Which command starts a MySQL container named 'mysql-dev' with root password 'rootpass'?
Adocker run --name mysql-dev -e MYSQL_ROOT_PASSWORD=rootpass -p 3306:3306 -d mysql
Bdocker start mysql-dev -p 3306
Cdocker build mysql-dev --password rootpass
Ddocker create mysql-dev -e MYSQL_PASSWORD=rootpass
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.