How to Identify and Stop and Remove a Docker Container

This pertains to Ubuntu Server 16.04 running Apache2.x, PHP7.x, and MySQL.  NextCloud 12 is installed and running on a domain with an SSL certificate issued by a public CA (on www.mydomain.tld and mydomain.tld).  I tried to integrate Collabora (Docker) obtaining its own SSL on a subdomain (office.mydomain.tld)

It became necessary to remove and reinstall the Collabora docker container / image. My two SSL certificates were conflicting after Collabora was installed and enabled in NextCloud 12. There was a failed configuration when I following the guided instructions for integrating Collabora online with NextCloud.  Incidentally, the installation mistake occurred  during the “run” phase. I mistakenly (and understandably) entered the sub-domain “office.mydomain.tld” (i.e. the subdomain where my collabora SSL certificate will address) rather than entering the already configured nextcloud domain www.mydomain.tld.  See the correct run command at the end of this Article.

Open terminal or putty ssh connection:

To See All docker containers:
sudo docker ps -a

To Stop a running docker container:
sudo docker stop <container id>
Example:
sudo docker stop 94fc7ad48626

Check the status again:
sudo docker ps -a

To Remove a stopped docker container:
sudo docker rm <container id>
Example:
sudo docker rm 94fc7ad48626

If there is an error at the removal step, it may be necessary to either restart apache or reboot the system.  Restarting Apache did not work for me.  I rebooted the system.

After reboot, check the status again and the container ID should be gone/empty. CONGRATULATIONS.  

When you reinstall Collabora:

Example to run the docker container referencing correct sub-domain of the previously installed nextcloud:
sudo docker run -t -d -p 127.0.0.1:9980:9980 -e ‘domain=nextcloud\\.your-domain\\.com’ –restart always –cap-add MKNOD collabora/code

I am not sure whether I should again first pull the docker Collabora/code before the docker run.  I will let you know.

 

Footnotes:  URL References / Credits:

https://docs.docker.com/engine/reference/commandline/stop/

https://help.nextcloud.com/t/collabora-docker-remove/4851

Print Friendly, PDF & Email