Skip to content

Removing Docker containers on delegate hosts

Occasionally, stopping the Control Center service leaves Docker containers in the local registry. Perform this procedure on each Control Center delegate host to ensure no containers remain.

  1. Gain access to the Control Center host, through the console interface of your hypervisor, or through a remote shell utility such as PuTTY.

  2. Start a command-line session as root.

    1. In the Appliance Administration menu, select Root Shell.
    2. Select Run, and then press Enter.

    The menu is replaced by a command prompt similar to the following example:

    [root@hostname ~]#
    
  3. Stop the Control Center service.

    systemctl stop serviced
    
  4. Ensure that no containers remain in the local repository.

    1. Display the identifiers of all containers, running and exited.

      docker ps -qa
      
      • If the command returns no result, proceed to the next step.
      • If the command returns a result, perform the following substeps.
    2. Remove all remaining containers.

      docker ps -qa | xargs --no-run-if-empty docker rm -fv
      
      • If the remove command completes, proceed to the next step.
      • If the remove command does not complete, the most likely cause is an NFS conflict. Perform the following substeps.
    3. Stop the NFS and Docker services.

      systemctl stop nfs && systemctl stop docker
      
    4. Start the NFS and Docker services.

      systemctl start nfs && systemctl start docker
      
    5. Repeat the attempt to remove all remaining containers.

      docker ps -qa | xargs --no-run-if-empty docker rm -fv
      
      • If the remove command completes, proceed to the next step.
      • If the remove command does not complete, perform the remaining substeps.
    6. Disable the automatic startup of serviced.

      systemctl disable serviced
      
    7. Reboot the host.

      reboot
      
    8. Log in to the delegate host as root or as a user with superuser privileges.

    9. Enable the automatic startup of serviced.

      systemctl enable serviced
      
  5. Dismount all filesystems mounted from the Control Center master host.

    This step ensures no stale mounts remain when the storage on the master host is replaced.

    1. Identify filesystems mounted from the master host.

      awk '/serviced/ { print $1, $2 }' < /proc/mounts | grep -v '/opt/serviced/var/isvcs'
      
      • If the preceding command returns no result, stop. This procedure is complete.
      • If the preceding command returns a result, perform the following substeps.
    2. Force the filesystems to dismount.

      for FS in $(awk '/serviced/ { print $2 }' < /proc/mounts | grep -v '/opt/serviced/var/isvcs')
      do
        umount -f $FS
      done
      
    3. Identify filesystems mounted from the master host.

      awk '/serviced/ { print $1, $2 }' < /proc/mounts | grep -v '/opt/serviced/var/isvcs'
      
      • If the preceding command returns no result, stop. This procedure is complete.
      • If the preceding command returns a result, perform the following substeps.
    4. Perform a lazy dismount.

      for FS in $(awk '/serviced/ { print $2 }' < /proc/mounts | grep -v '/opt/serviced/var/isvcs')
      do
        umount -f -l $FS
      done
      
    5. Restart the NFS service.

      systemctl restart nfs
      
    6. Determine whether any filesystems remain mounted from the master host.

      awk '/serviced/ { print $1, $2 }' < /proc/mounts | grep -v '/opt/serviced/var/isvcs'
      
      • If the preceding command returns no result, stop. This procedure is complete.
      • If the preceding command returns a result, perform the remaining substeps.
    7. Disable the automatic startup of serviced.

      systemctl disable serviced
      
    8. Reboot the host.

      reboot
      
    9. Log in to the delegate host as root, or as a user with superuser privileges.

    10. Enable the automatic startup of serviced.

      systemctl enable serviced
      

To return to the Appliance Administration menu, enter the exit command.