6. Content Management Systems (CMS) - Mark-van-B/IT-Landscape-UCLL- GitHub Wiki
Introduction
CMS are tools that make it easy for users to change the content of a website without the need of technical skills (html/CSS/JavaScript, or any framework built around those).
In this example, I am going to use WordPress, simply because it's one of the most widely used examples out there.
Installation
Step 1: create an empty Wordpress container.
- Open Docker Desktop, and click on
>_ Terminal
at the bottom of the window.
- In it: write
docker run --name <custom_name> -p <local_port you'd want to use, 8080:80 is fine> -d wordpress
( -d ="detach", which makes it run in the background, "wordpress" makes it a WordPress container)
- Once it's all done, you'll have the WordPress container listed in the Containers tab of Docker Desktop:
- From here, you could already go the Containers tab in Docker Desktop, expand the wordpress container, and click on the Port link to open it:
- However, it'll quickly start asking about database details you won't have, so...
Step 2: include a database
- Open File Explorer, create a new folder somewhere, enter it, and rightclick -> New -> Text Document.
- Make sure that you can see the file extensions, here's where they hid the option in Windows 11:
- Rename "New Text Document.txt" to "compose.yaml" (see Docker Compose).
- Open it with Visual Studio Code, and paste the following text into it. Don't forget to save (Ctrl+S) afterwards!
services:
wordpress:
image: wordpress:latest
ports:
- "8000:80"
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: user
WORDPRESS_DB_PASSWORD: password
WORDPRESS_DB_NAME: wordpress
volumes:
- wordpress_data:/var/www/html
db:
image: mysql:5.7
environment:
MYSQL_DATABASE: wordpress
MYSQL_USER: user
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: rootpassword
volumes:
- db_data:/var/lib/mysql
volumes:
wordpress_data:
db_data:
NOTE: The database, user, and password need to be identical in both "environment: sections", but you are free to put whatever username/PW you want in there.
- No, really, don't forget to save! (Ctrl+ S))
- Open a Terminal (Right-click the Start Menu icon, choose "Run" from the menu, type
cmd
into it)
- Orient it towards the folder of compose.yaml:
- Right click compose.yaml in the file explorer, copy as path
- Go back to the Terminal, type
cd
(with a space after it), and right click in the Terminal to paste the filepath. Mine has a space between IT and Landscape, so I was forced to put the entire thing between double quotes. - Then run
docker-compose up -d
(the -d is optional, but it makes things run in the background)
Step 3: Enter the WordPress environment
- Once that's all done, go back to localhost:8000 if the container is still running, otherwise redo the "docker run" command from above.
- IF it asks for it: enter database host, database name, username, and password you specified in compose.yaml:
- If not, just fill in the form with your username etc, and we're good to go!