0
0
ML Pythonml~10 mins

Docker containerization in ML Python - Interactive Code Practice

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

Complete the code to specify the base image in a Dockerfile.

ML Python
FROM [1]
Drag options to blanks, or click blank then click option'
Apython:3.8-slim
BCOPY . /app
CRUN apt-get update
DCMD python app.py
Attempts:
3 left
💡 Hint
Common Mistakes
Using RUN or COPY instead of FROM as the first instruction.
Specifying commands instead of an image name.
2fill in blank
medium

Complete the code to copy the current directory contents into the container.

ML Python
COPY [1] /app
Drag options to blanks, or click blank then click option'
Arequirements.txt
Bapp.py
C/usr/src/app
D.
Attempts:
3 left
💡 Hint
Common Mistakes
Copying a single file instead of the whole directory.
Using an absolute path from the container as source.
3fill in blank
hard

Fix the error in the command to install dependencies inside the container.

ML Python
RUN pip install [1]
Drag options to blanks, or click blank then click option'
Arequirements.txt
B-r requirements.txt
Cinstall requirements.txt
Dpip install -r requirements.txt
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the whole command including 'pip install' in the blank.
Omitting the '-r' flag.
4fill in blank
hard

Fill both blanks to set the working directory and the command to run the app.

ML Python
WORKDIR [1]
CMD ["python", "[2]"]
Drag options to blanks, or click blank then click option'
A/app
Bapp.py
Cmain.py
D/usr/src/app
Attempts:
3 left
💡 Hint
Common Mistakes
Using an incorrect path for WORKDIR.
Specifying the wrong script name in CMD.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps file names to their sizes if size is greater than 1000 bytes.

ML Python
file_sizes = [1]: os.path.getsize([2]) for [3] in files if os.path.getsize([3]) > 1000
Drag options to blanks, or click blank then click option'
Af
Dfilename
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names in different parts of the comprehension.
Not using the variable as the key in the dictionary.