Thinking image must be built locally before pulling
Confusing image name typos with tag errors
5. You want to pull the latest version of the official Redis image but only if it is not already downloaded locally. Which command sequence achieves this efficiently?
hard
A. docker images | grep redis || docker pull redis
B. if ! docker images redis | grep redis; then docker pull redis; fi
C. docker pull redis:latest && echo 'Pulled latest Redis'
D. docker pull redis
Solution
Step 1: Understand the goal
Pull the latest Redis image only if missing or outdated locally to avoid unnecessary downloads.
Step 2: Analyze each option
docker pull redis fetches the latest manifest and downloads only changed/missing layers ('Image is up to date' if current). B and D skip entirely if any 'redis' image exists (even outdated/no :latest), missing updates. C always pulls and echoes.
Final Answer:
docker pull redis -> Option D
Quick Check:
docker pull redis downloads only if needed [OK]
Hint: docker pull redis downloads only if needed [OK]
Common Mistakes:
Shell scripts skip updates if old redis image present
Thinking docker pull always downloads layers
Confusing existence check with up-to-date check
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.