Title: Quiz 2 — Docker Fundamentals: Running and Managing Containers
Course: AIINFRA 101: Applied Infrastructure & Containerization > Section: Week 02 — Docker Fundamentals: Running & Managing Containers

Q: What does docker run do that docker start does not?
- Lists running containers
- Creates a new container from an image before starting it
- Opens an interactive shell
- Removes a stopped container
A: Creates a new container from an image before starting it

Q: docker ps (with no flags) shows every container on the system, including stopped ones.
- True
- False
A: False

Q: Which command lets you run an additional command inside a container that is already running, without restarting it?
- `docker run`
- `docker restart`
- `docker exec`
- `docker build`
A: `docker exec`

Q: What do the -it flags do when added to docker run?
Feedback: Sample/expected answer: They provide an interactive terminal session: ****`-i`**** keeps STDIN open, and ****`-t`**** allocates a pseudo-TTY, together giving you a live interactive shell inside the container.

Q: You start a container with docker run -d nginx. What happens?
- The container runs in the foreground and blocks your terminal
- The container runs in the background and control returns immediately to your terminal
- Docker asks for interactive input
- The container is deleted automatically after it starts
A: The container runs in the background and control returns immediately to your terminal

Q: In the command docker run -p 8080:80 nginx, which port is the host port and which is the container port?
Feedback: Sample/expected answer: 8080 is the host port (left side); 80 is the container port (right side). Traffic arriving on the host's port 8080 is forwarded to port 80 inside the container.

Q: If you install a package inside a running container and then remove that container, the package will still be there the next time you run a new container from the same image.
- True
- False
A: False

Q: Which flag would you add to docker run to limit a container to at most 512 MB of RAM?
- `--cpus=512`
- `-p 512:512`
- `-m 512m`
- `-it 512m`
A: `-m 512m`