Originally I used docker-compose for work, but I felt like "use this command with a setting made by someone".
Suddenly, I wanted to create a new Wordpress / grafana / node-red.
At first, I could use Hyper-V, so I thought I should make it as one image on Hyper-V, but it's strange in terms of network. (Httpss on github is denied ...) I gave up because I didn't know the solution anymore.
I somehow knew that docker-compose could be used by downloading the application / system I wanted to use, so I asked, "Well, let's try docker-compose."
I'm still not sure about it deeply, but I'll make a note of the information I referred to.
--Gugu Docker-for-Get to Windows and install with installer - https://docs.docker.com/docker-for-windows/install/ --Because it was configured on Hyper-V before, the installation procedure should have been different between Win10 Pro and Home, but now it seems to use WSL (performance seems to be better here), so it may be the same at Home unknown --Hyper-V ... Do you need it anymore ...? --If WSL is not installed, when setting Docker-Desktop after installation, it will say "Do not move until WSL is installed", so install WSL according to the dialog.
For the time being, I knew that if I wrote docker-compose.yml, it would be downloaded and built, so I will write it. But I don't know what to write.
--How to write Wordpress in docker-compose - https://docs.docker.jp/compose/wordpress.html --Copy and paste is fine ――You can understand the contents of the settings by reading
Start Power Shell with administrator privileges
> docker-compose up -d
I know this because I use it at work.
Start Power Shell with administrator privileges
> docker-compose down
When dropping the entire volume (where the settings are stored. If the volume is not specified in the DB, the data will be deleted every time docker is dropped)
> docker-compose down -v
And I notice that the Wordpress language settings are not saved.
The above-mentioned Wordpress specifications are as follows.
docker-compose.yml
version: '3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
volumes:
db_data:
I understand that "Ah, db_data of volumes of db is saved in association with db_data of volumes".
docker-compose.yml
version: '3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
volumes:
- wordpress_html:/var/www/html
volumes:
db_data:
wordpress_html:
The above specification makes it difficult to understand the volume path from the windows path. On the referenced site
wordpress:
volumes:
- ./wordpress/html:/var/www/html
I don't use volumes at the same level as wordpress. I think this is the difference between creating a shared directory for the volume in the specified path or trusting Docker to automatically create the volume somewhere. (I stopped doing the above because I couldn't access the DB after doing it several times .. Maybe the files in the directory were corrupted or something ...)
--Path to be set in wordpress volumes - https://qiita.com/tomokei5634/items/75d2501cfb968d0cfab5 --Explanation for specifying volumes - https://qiita.com/gentaro/items/7dec88e663f59b472de6#drvfs%E3%81%AE%E9%9A%8E%E5%B1%A4%E3%82%92%E6%8C%87%E5%AE%9A%E3%81%97%E3%81%9F%E5%A0%B4%E5%90%88 --References on volumes - https://docs.docker.jp/compose/compose-file.html?highlight=volumes#volumes-volume-driver
--How to use multiple DBs - https://www.it-swarm-ja.tech/ja/database/%E8%A4%87%E6%95%B0%E3%81%AE%E3%83%87%E3%83%BC%E3%82%BF%E3%83%99%E3%83%BC%E3%82%B9%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%9Fdockercompose/826471742/ --How to set grafana to docker-compose - https://qiita.com/Rayleigh/items/4da75f467cab385d1006 --I wanted to use a plugin other than Grafana Cloud, so I don't use top-level volumes.
In Hyper-V, it was packed for days if https did not pass to create one environment of Wordpress, but with docker-compose, 4 containers could be created in 2 hours. This falls in love with docker-compose.
Recommended Posts