0
0
Dockerdevops~10 mins

Building images with docker build - Interactive Code Practice

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

Complete the command to build a Docker image from the current directory.

Docker
docker build [1] .
Drag options to blanks, or click blank then click option'
A-p 8080:80
B-d
C-t myimage
D--rm
Attempts:
3 left
💡 Hint
Common Mistakes
Using -d which is for running containers, not building images.
Using -p which is for port mapping when running containers.
Using -rm which is not a valid docker build flag.
2fill in blank
medium

Complete the command to build a Docker image using a specific Dockerfile named 'Dockerfile.dev'.

Docker
docker build -f [1] .
Drag options to blanks, or click blank then click option'
ADockerfile.txt
BDockerfile.dev
Cdockerfile
DDockerfile.prod
Attempts:
3 left
💡 Hint
Common Mistakes
Using a file name that does not exist.
Using lowercase 'dockerfile' which is not the correct file name.
Using a file with wrong extension like .txt.
3fill in blank
hard

Fix the error in the command to build an image with tag 'webapp:latest'.

Docker
docker build -t [1] .
Drag options to blanks, or click blank then click option'
Awebapp_latest
Bwebapp latest
Cwebapp/latest
Dwebapp:latest
Attempts:
3 left
💡 Hint
Common Mistakes
Using a slash '/' instead of a colon ':'.
Using spaces in the tag name.
Using underscores which are allowed but not standard for tags.
4fill in blank
hard

Fill both blanks to build an image with tag 'app:v1' and no cache.

Docker
docker build [1] [2] .
Drag options to blanks, or click blank then click option'
A--no-cache
B-t app:v1
C-f Dockerfile
D--rm
Attempts:
3 left
💡 Hint
Common Mistakes
Using --rm which removes intermediate containers but does not disable cache.
Using -f Dockerfile which is default and not needed here.
Reversing the order of options is allowed but can confuse beginners.
5fill in blank
hard

Fill all three blanks to build an image named 'backend' with tag 'v2', using Dockerfile 'Dockerfile.prod' and no cache.

Docker
docker build [1] [2] [3] .
Drag options to blanks, or click blank then click option'
A-f Dockerfile.prod
B-t backend:v2
C--no-cache
D--pull
Attempts:
3 left
💡 Hint
Common Mistakes
Using --pull instead of --no-cache.
Omitting the Dockerfile option when a custom file is needed.
Incorrect tag format or missing tag.