[{"id":"dockerbeginner-001","courseId":"docker-beginner","domain":"images-builds","topic":"Image layers","prompt":"A theoretical Python app image is built from five layers. Put these layers in the order they are added, from the first layer to the last.","hint":"Each layer can only use what the layers beneath it already provide.","explain":"An image is a stack of layers, and each layer holds the filesystem changes made on top of the one below it. A layer can rely only on what earlier layers have installed or copied.","source":"https://docs.docker.com/get-started/docker-concepts/building-images/understanding-image-layers/","interaction":{"type":"sort","items":[{"text":"Adds basic commands and a package manager such as apt","why":"This is the base the other layers stack on, so it is added first."},{"text":"Installs a Python runtime and pip","why":"It adds the language and its package installer on top of the base, which the later layers need."},{"text":"Copies in the application's requirements.txt file","why":"The dependency list has to be present before the dependencies can be installed from it."},{"text":"Installs the application's specific dependencies","why":"It uses pip from the layer below and the requirements file copied in just before it."},{"text":"Copies in the application's source code","why":"The app's own code is added last, once the dependencies it needs are already in place."}]},"options":[],"answer":"o:abcde","explanation":"Each image layer records filesystem changes and stacks on the layers below it, so a layer can use only what earlier layers provide.","concept":"Each image layer records filesystem changes and stacks on the layers below it, so a layer can use only what earlier layers provide.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Each layer builds on the one below it, so layer order decides what later layers can use."]},{"id":"dockerbeginner-002","courseId":"docker-beginner","domain":"images-builds","topic":"FROM instruction","prompt":"A Dockerfile whose first instruction is RUN apt-get update, with FROM ubuntu on the next line, is still a valid Dockerfile.","hint":"Consider which instruction a Dockerfile has to begin with.","explain":"Each build stage names the image it builds on, and the rest of the stage comes after that. Think about what the file must start with before any other instruction can run.","source":"https://docs.docker.com/reference/dockerfile/#from","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","whyNot":"Only ARG may come before FROM, so a RUN placed before it makes the Dockerfile invalid."},{"id":"b","text":"False","why":"A valid Dockerfile must start with FROM; ARG is the only exception, so RUN has to come after FROM."}],"answer":"b","explanation":"A valid Dockerfile starts with FROM, which begins a build stage and sets its base image; ARG is the only instruction allowed before it.","concept":"A valid Dockerfile starts with FROM, which begins a build stage and sets its base image; ARG is the only instruction allowed before it.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Every Dockerfile starts with FROM; the only instruction allowed before it is ARG."]},{"id":"dockerbeginner-003","courseId":"docker-beginner","domain":"images-builds","topic":"CMD instruction","prompt":"A Dockerfile has RUN make install, then CMD [\"./app\"]. You run docker build, then docker run on the image. When does ./app start?","hint":"Compare what runs during the build with what runs when a container starts.","explain":"Some Dockerfile instructions run commands while the image is built, and others only record what should happen later. Think about which kind CMD is, and when a container's command runs.","source":"https://docs.docker.com/reference/dockerfile/#cmd","interaction":{"type":"single"},"options":[{"id":"a","text":"When docker run starts a container from the image","why":"CMD sets the default command for containers started from the image, so it runs at container start."},{"id":"b","text":"During docker build, right after make install","whyNot":"That describes RUN, which executes commands at build time; CMD doesn't execute anything during the build."},{"id":"c","text":"During docker build, so its output is saved in a layer","whyNot":"Only RUN saves the result of a command as a layer; CMD only records the default command."},{"id":"d","text":"When docker push uploads the image to a registry","whyNot":"Pushing copies the image to a registry without starting any of its commands."}],"answer":"a","explanation":"CMD executes nothing at build time; it sets the default command a container runs when started from the image, while RUN executes during the build.","concept":"CMD executes nothing at build time; it sets the default command a container runs when started from the image, while RUN executes during the build.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","code":"RUN make install\nCMD [\"./app\"]","takeaways":["RUN works at build time; CMD only sets what runs when a container starts."]},{"id":"dockerbeginner-004","courseId":"docker-beginner","domain":"images-builds","topic":"COPY instruction","prompt":"A Dockerfile contains COPY test.txt /abs with no trailing slash, and /abs does not exist yet. What does the build create at /abs?","hint":"Look closely at the slash at the end of the destination path.","explain":"COPY places a source file at the destination you give. How the destination is written decides whether it names the new file itself or a folder to put the file inside.","source":"https://docs.docker.com/reference/dockerfile/#copy","interaction":{"type":"single"},"options":[{"id":"a","text":"A file named /abs holding the contents of test.txt","why":"Without a trailing slash, the destination is the file's own path, so the copy is written to /abs as a file."},{"id":"b","text":"A directory named /abs with test.txt inside it","whyNot":"That is what a trailing slash produces: /abs/ is treated as a folder to copy into."},{"id":"c","text":"A file at /abs/test.txt","whyNot":"A trailing slash on the destination would produce this; without it, the name /abs is the file itself."},{"id":"d","text":"An error, because COPY needs a trailing slash","whyNot":"COPY accepts both forms; the slash only changes how the destination is read."}],"answer":"a","explanation":"Trailing slashes are significant: COPY test.txt /abs creates a file at /abs, while COPY test.txt /abs/ creates /abs/test.txt.","concept":"Trailing slashes are significant: COPY test.txt /abs creates a file at /abs, while COPY test.txt /abs/ creates /abs/test.txt.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","code":"COPY test.txt /abs","takeaways":["A trailing slash on a COPY destination changes whether it names a file or a folder."]},{"id":"dockerbeginner-005","courseId":"docker-beginner","domain":"images-builds","topic":"ADD extraction and URL fetching","prompt":"A Dockerfile needs files in the image and uses ADD for them. Which TWO statements about ADD are correct?","hint":"Think about what ADD does differently from COPY depending on the kind of source.","explain":"ADD places a source into the image, but its source can be more than a path in the build context. Read how it treats local archives and remote addresses.","source":"https://docs.docker.com/reference/dockerfile/#add","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"ADD extracts a local tar archive into the destination directory.","why":"A local archive in a recognized compression format, or uncompressed, is decompressed and extracted into the destination."},{"id":"b","text":"ADD downloads a URL source and places its contents at the destination.","why":"When the source is a URL, its contents are fetched and placed at the destination path."},{"id":"c","text":"ADD copies a local tar archive into the image unopened.","whyNot":"A local tar archive used as an ADD source is extracted, not stored as a single file."},{"id":"d","text":"ADD and COPY are interchangeable in every case.","whyNot":"They are only functionally similar; ADD adds URL fetching and archive extraction that COPY lacks."},{"id":"e","text":"ADD rejects URL sources, so files must be fetched with RUN.","whyNot":"ADD accepts a URL as its source and downloads it into the destination."},{"id":"f","text":"ADD runs the file it copies when the container starts.","whyNot":"ADD only places files into the image; CMD is the instruction that sets a command to run at start."}],"answer":"ab","explanation":"ADD goes beyond COPY: it extracts local tar archives and downloads URL sources into the image, though it is functionally similar to COPY.","concept":"ADD goes beyond COPY: it extracts local tar archives and downloads URL sources into the image, though it is functionally similar to COPY.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["ADD handles local archives and URLs; COPY only copies files and folders."]}]