Question 1: Docker Exec vs Attach
What is the difference between docker exec and docker attach when working with containers?
Give an example scenario where you would use each.
Docker exec is used to run or execute commands in a running container.
Use -You are running a web server in a container and want to inspect logs or install without affecting the server.
Docker attach connects the terminal to the main process of the container [pid 1]
Note: if we exit after attaching to container it stop the container because we it would be terminating the PID 1.
Trick: Ctrl+P then Crtl+Q to deattach without stopping the container.
Use - you started a container with a shell and want to reconnect it.
Question 2: Docker Wait vs Docker Update
Explain the difference between the docker wait and docker update commands.
When would you use docker wait, and when would you use docker update?
docker waits to pause the terminal the container stops, then prints its exit code
Use: when you are automating and to wait for a container to finish before running the next step.
docker update is used to modify resource (like cpu , memory ) for existing container.
Use: when you want ot change resource limits (lik --cpus=1)