Great questions. Let me try answering them..
For point number 2, you have the wordpress installation in the "wordpress" folder under your project. This is the volume mapping that achieves that..
Code:
https://github.com/noc2spam/wp-on-docker/blob/e7383465ccf1a7bde7cec581be82d121662a5649/docker-compose.yaml#L23
Instead of persisting the whole wordpress folder, you could also persist only the wp-content, because that's what you need for 99.99% times. For achieving that, change the line to the following:
Code:
- ./wp-content:/var/www/html/wp-content
If you want to develop locally, don't use the docker-compose file on the server directly. Instead, install docker desktop and git on your dev machine, clone this repo to your dev machine:
Code:
https://github.com/noc2spam/wp-on-docker
remove the following line from the .gitignore:
Code:
https://github.com/noc2spam/wp-on-docker/blob/e7383465ccf1a7bde7cec581be82d121662a5649/.gitignore#L3
and start developing! As you removed the wordpress folder from ignored folders, the whole folder will now be part of the repo as well. You now can push the modified code to your own repository (git remote add downstream yourgiturl && git push downstream master) and use that instead of my example wp-on-docker repo.
For point number 3 & 4, you can follow the same tutorial and install the blogs on multiple folders (e.g. ~/sites/project1, ~/sites/project2 etc), but you will need to change the exposed ports:
Code:
https://github.com/noc2spam/wp-on-docker/blob/e7383465ccf1a7bde7cec581be82d121662a5649/docker-compose.yaml#L20
and
Code:
https://github.com/noc2spam/wp-on-docker/blob/e7383465ccf1a7bde7cec581be82d121662a5649/docker-compose.yaml#L33
Change the 2023 and 2024 to something else like 2025 and 2026.
Subdomains will also work in the exact same way. In the tutorial, I used @, www, pma as the sub domain host parts. You could follow that same pattern and add let's say add:
Code:
host: project2, ip: sameip, TTL: leave it default
host: pma2, ip: sameip, TTL: leave it default
Then use the same gist content:
Code:
https://gist.github.com/noc2spam/241b1a0e0b9083b8769c37937463775c
Here, change the host to project2.domain.com and pma2.domain.com. Also change the proxy_pass url to the new ports e.g.
http://127.0.0.1:2025 and
http://127.0.0.1:2026.
As for point number 1, you could see the logs by typing:
Code:
docker logs containername
You can find out the containername by issuing:
You can check RAM usage by issuing:
You could also go to the project folder and issue
That will connect you up with the current running stack and you will be able to see the live log from there. Just press ctrl + z to exit without stopping the containers.
If you are interested, I would recommend reading up on docker a little more. These are big topics and hard to explain everything in a post.
Also remember, all these things can be automated with something like Ansible. If you learn Ansible with Docker, you can make an ansible script which will do everything for you with just one command. You could even take backup etc with ansible. I did not explain that in the original post because I don't want to burdain you with more knowledge being a beginner. If you are interested, please feel free to read up.