0
0
Dockerdevops~10 mins

Database containers for local development in Docker - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the command to start a PostgreSQL container named 'pg_local' with the latest image.

Docker
docker run --name pg_local -e POSTGRES_PASSWORD=mysecretpassword -d [1]
Drag options to blanks, or click blank then click option'
Amongo:latest
Bpostgres:latest
Cmysql:latest
Dredis:latest
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-PostgreSQL image like MySQL or MongoDB.
2fill in blank
medium

Complete the command to map the container's port 5432 to the host's port 5433.

Docker
docker run -p [1]:5432 postgres
Drag options to blanks, or click blank then click option'
A5433
B5432
C3306
D27017
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the ports or using default container port as host port.
3fill in blank
hard

Fix the error in the command to persist PostgreSQL data in a Docker volume named 'pgdata'.

Docker
docker run -v [1]:/var/lib/postgresql/data postgres
Drag options to blanks, or click blank then click option'
Apgdata:/var/lib/postgresql/data
B/pgdata
Cpgdata
Dpgdata_volume
Attempts:
3 left
💡 Hint
Common Mistakes
Using a path instead of a volume name, or adding extra slashes.
4fill in blank
hard

Fill both blanks to run a MySQL container with root password 'rootpass' and expose port 3307 on host.

Docker
docker run -e [1]=rootpass -p [2]:3306 mysql
Drag options to blanks, or click blank then click option'
AMYSQL_ROOT_PASSWORD
B3306
C3307
DMYSQL_PASSWORD
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong environment variable or wrong port mapping.
5fill in blank
hard

Fill all three blanks to create a Docker Compose service for PostgreSQL with volume and port mapping.

Docker
services:
  db:
    image: [1]
    ports:
      - "[2]:5432"
    volumes:
      - [3]:/var/lib/postgresql/data
Drag options to blanks, or click blank then click option'
Apostgres:13
B5433
Cpgdata
Dmysql:8
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong image, port, or volume name.