0
0
Dockerdevops~10 mins

Building images in CI pipeline in Docker - Interactive Code Practice

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

Complete the code to build a Docker image named 'myapp' using the Dockerfile in the current directory.

Docker
docker build -t myapp [1] Dockerfile .
Drag options to blanks, or click blank then click option'
A-f
B-d
C-b
D-p
Attempts:
3 left
💡 Hint
Common Mistakes
Using -d which is for detached mode in other commands.
Using -p which is for port mapping.
Using -b which is not a valid Docker build option.
2fill in blank
medium

Complete the command to push the Docker image 'myapp' to the Docker Hub repository 'username/myapp'.

Docker
docker [1] username/myapp
Drag options to blanks, or click blank then click option'
Arun
Bpull
Cbuild
Dpush
Attempts:
3 left
💡 Hint
Common Mistakes
Using pull which downloads images.
Using run which starts containers.
Using build which creates images locally.
3fill in blank
hard

Fix the error in the GitHub Actions step to build a Docker image with tag 'latest'.

Docker
      - name: Build Docker image
        run: docker build -t myapp[1] .
Drag options to blanks, or click blank then click option'
A-latest
B:latest
C latest
D/latest
Attempts:
3 left
💡 Hint
Common Mistakes
Using a dash - instead of colon.
Adding a space before the tag.
Using a slash / which is for repository names.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps branch names to their Docker image tags, only for branches starting with 'release'.

Docker
images = {branch: branch[1] 'v1' for branch in branches if branch.[2]('release')}
Drag options to blanks, or click blank then click option'
A+
B==
Cstartswith
Din
Attempts:
3 left
💡 Hint
Common Mistakes
Using == instead of startswith for string prefix check.
Using in which checks substring anywhere.
Using - or other operators instead of + for string join.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps service names (uppercase) to their version numbers, only if version is greater than 0.

Docker
service_versions = { [1]: [2] for [3], version in services.items() if [2] > 0}
Drag options to blanks, or click blank then click option'
Aname.upper()
Bversion
Cname
Dservice
Attempts:
3 left
💡 Hint
Common Mistakes
Using service instead of name as loop variable.
Not converting name to uppercase.
Using wrong variable names causing errors.