Lab 003: Docker Delete Container
Requirements
One of the Nautilus project developers created a container on App Server 2. This container was created for testing only and now we need to delete it. Accomplish this task as per details given below:
Delete a container named kke-container, its running on App Server 2 in Stratos DC.
Note
This page preserves the original requirement text and documents one safe stop-and-remove workflow for the target container.
Prerequisites
- You can SSH to App Server 2 and switch to a privileged shell.
- Docker is installed and the daemon is running on the host.
- The container kke-container exists on the host before you start the removal steps.
Steps
Login to the app server 2 and switch to root. For the server credentials, check out the Project Nautilus documentation.
sshpass -p '********' ssh -o StrictHostKeyChecking=no steve@172.16.238.11
sudo su -
********
Check the running containers.
[root@stapp02 ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6cc8799c69a1 busybox "tail -f /dev/null" About a minute ago Up About a minute kke-container
Stop the container then delete it. Verify afterwards.
[root@stapp02 ~]# docker stop kke-container
kke-container
[root@stapp02 ~]# docker rm kke-container
kke-container
[root@stapp02 ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Verification
- Confirm the container no longer exists with
docker ps -a | grep kke-container. - If the grep command returns no output, the removal is complete.