DEV Community

Cover image for 3.Delete Docker Container
Thu Kha Kyawe
Thu Kha Kyawe

Posted on

3.Delete Docker Container

Lab Information

A container named kke-container was created by one of the Nautilus project developers on App Server 3. It was solely for testing purposes and now requires deletion. Execute the following task:

Delete the kke-container on App Server 3 in Stratos DC.

Lab Solutions

βœ… Part 1: Exact KodeKloud Lab Guidelines (Exam-Safe Mode)
πŸ”‘ Step 0: Login to Application Server 3

From the jump host:

ssh banner@stapp03

Password:

BigGr33n

πŸ—‘οΈ Step 1: Stop the container

docker ps
docker stop kke-container
Enter fullscreen mode Exit fullscreen mode

❌ Step 2: Delete the container

docker rm kke-container
Enter fullscreen mode Exit fullscreen mode

πŸ” Step 3: Verification (MANDATORY)

docker ps -a
Enter fullscreen mode Exit fullscreen mode

Expected result

kke-container is not listed

⚠️ Common Lab Mistakes to Avoid

❌ Deleting container on wrong server

❌ Removing image instead of container

❌ Forgetting to stop a running container before removal

❌ Using incorrect container name


🧠 Part 2: Simple Step-by-Step Explanation
πŸͺœ What’s happening?

Containers cannot be removed while running

We stop it first to avoid errors.

Removing deletes container metadata

The image remains untouched (this is expected).

πŸ” Command Breakdown
docker stop kke-container

Gracefully stops the container

docker rm kke-container

Permanently removes the container

🧠 Exam Memory Hook

Stop β†’ Remove β†’ Verify

Always confirm with:

docker ps -a


Resources & Next Steps
πŸ“¦ Full Code Repository: KodeKloud Learning Labs
πŸ“– More Deep Dives: Whispering Cloud Insights - Read other technical articles
πŸ’¬ Join Discussion: DEV Community - Share your thoughts and questions
πŸ’Ό Let's Connect: LinkedIn - I'd love to connect with you

Credits
β€’ All labs are from: KodeKloud
β€’ I sincerely appreciate your provision of these valuable resources.

Top comments (0)