0
0
Dockerdevops~10 mins

Running tests in containers 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 run tests inside a Docker container.

Docker
docker run --rm [1] myapp:test
Drag options to blanks, or click blank then click option'
A--name
B-d
C--rm
D-it
Attempts:
3 left
💡 Hint
Common Mistakes
Using --rm twice causes an error.
Using -d runs container in background, hiding test output.
2fill in blank
medium

Complete the command to mount the current directory inside the container for testing.

Docker
docker run --rm -v [1]:/app myapp:test
Drag options to blanks, or click blank then click option'
A$(pwd)
B/home/user/project
C/app
D/var/lib/docker
Attempts:
3 left
💡 Hint
Common Mistakes
Hardcoding paths can cause errors on different machines.
Using container paths instead of host paths for volume mount.
3fill in blank
hard

Fix the error in the command to run tests with environment variables.

Docker
docker run --rm -e [1] myapp:test
Drag options to blanks, or click blank then click option'
AENV
BENV=production
CENV=production debug=true
DENV production
Attempts:
3 left
💡 Hint
Common Mistakes
Using space instead of equals sign causes syntax error.
Passing multiple variables in one -e option is invalid.
4fill in blank
hard

Fill both blanks to run tests in detached mode and name the container.

Docker
docker run [1] [2] myapp:test
Drag options to blanks, or click blank then click option'
A-d
B--rm
C--name test_container
D-it
Attempts:
3 left
💡 Hint
Common Mistakes
Using -it with detached mode causes conflicts.
Forgetting to name the container makes management harder.
5fill in blank
hard

Fill all three blanks to build an image, tag it, and run tests inside the container.

Docker
docker build -t [1] . && docker run --rm -v [2]:/app [3] myapp:test
Drag options to blanks, or click blank then click option'
Amyapp:test
B$(pwd)
D-it
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing image tag and container name.
Not mounting the directory causes tests to run on old code.
Running without interactive mode hides output.