Step 1: Clean Up#
Remove Previous Wordpress Containers#
We need to stop the Wordpress project and remove the containers before we rebuild the project. As you will learn, Docker containers are disposable when using volumes because the data and configurations reside outside of the containers. The containers load that data so users can interact with it.
Change to the Wordpress folder using
cd ~/wordpress-dockerStop the project using the command
docker-compose down -vUsing the
-vflag removes the data associated with the container.
Remove any stopped containers or containers that you no longer want running.
View stopped containers:
docker ps -aRemove a stopped container using the CONTAINER ID:
docker rm 1234567890
root@vps298933:~/wordpress-docker# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 925b57e101a5 hello-world "/hello" 5 minutes ago Exited (0) 4 minutes ago pensive_sammet 2175f0a86466 nextcloud "/entrypoint.sh apac…" 7 days ago Up 6 days 0.0.0.0:20850->80/tcp condescending_agnesi root@vps298933:~/wordpress-docker# root@vps298933:~/wordpress-docker# docker rm 925b57e101a5 925b57e101a5 root@vps298933:~/wordpress-docker# root@vps298933:~/wordpress-docker# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2175f0a86466 nextcloud "/entrypoint.sh apac…" 7 days ago Up 6 days 0.0.0.0:20850->80/tcp condescending_agnesi root@vps298933:~/wordpress-docker#
Clean up any dangling volumes using
docker volume prunePhysically remove any data stored in the volume directory or
db_datausing commandrm -r db_dataThe
wordpress-dockerdirectory should containdocker-compose.ymlonly.root@vps298933:~/wordpress-docker# ls -lh total 4.0K -rw-r--r-- 1 root root 593 Mar 23 17:43 docker-compose.yml root@vps298933:~/wordpress-docker#
Source & license
Reproduced verbatim, without modification from © 2022, BilimEdtech Labs, licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).
Source page: https://labs.bilimedtech.com/cloud-computing/3/3.1.html
See LICENSE for the full license text.