Know the convenience of Docker (-compose) now (information list that I referred to when using it)

Trigger

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.

Install Docker on Windows

--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.

Create docker-compose.yml

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.

Referenced information

--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 docker

Start Power Shell with administrator privileges

> docker-compose up -d

I know this because I use it at work.

drop docker

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.

About setting volumes

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 ...)

Referenced information

--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

After that, what I referred to when incorporating grafana and others

--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.

Impressions

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

Know the convenience of Docker (-compose) now (information list that I referred to when using it)
[Docker] List of errors that occurred when building the environment
When I started ansible + docker now, I stumbled from the beginning, but I managed to start it
I want to know the JSP of the open portlet when developing Liferay
I tried to summarize the state transition of docker
I want to know the answer of the rock-paper-scissors app
I tried to investigate the mechanism of Emscripten by using it with the Sudoku solver
List of Docker commands that I often use (container operation)
[Java] To know the type information of type parameters at runtime
I have summarized the articles that programming beginners referred to.
I tried to build the environment little by little using docker
I tried to build the environment of WSL2 + Docker + VSCode
I want to narrow down the display of docker ps
What I was addicted to when updating the PHP version of the development environment (Docker) from 7.2.11 to 7.4.x
I made a GitHub Action that makes it easy to understand the execution result of RSpec
I tried to build the environment of PlantUML Server with Docker
The story of Collectors.groupingBy that I want to keep for posterity
I examined the concept of the process to understand how Docker works
I want to notice that I forgot to specify arg when building Docker
AWS SAM CLI now supports local emulation of HttpApi, so I tried using it on WSL2 Docker
[Rails] I was addicted to the nginx settings when using Action Cable.
A story I was addicted to when testing the API using MockMVC
Glassfish tuning list that I want to keep for the time being
Problems I was addicted to when building the digdag environment with docker
After all I wanted to preview the contents of mysql with Docker ...
Ideal and reality that I felt when I used Optional for the first time ~ Implementation of cache using Map ~
Let's specify the version when using docker
How to sort the List of SelectItem
When I pushed to Docker Hub, I got requested access to the resource is denied
What I tried when I wanted to get all the fields of a bean
Volume of optimizing Hyper-v to eliminate the tightness of disk capacity (engineer using Docker)
Up to the point of launching a Docker container built using RedHat Quarkus
Pay attention to the boundary check of the input value when using the float type
I managed to get a blank when I brought the contents of Beans to the textarea
I want to get the information of the class that inherits the UserDetails class of the user who is logged in with Spring Boot.
About the solution of the error that occurred when trying to create a Japanese file of devise in the Docker development environment
I want you to put the story that the error was solved when you stabbed the charger in the corner of your head
Apple Silicon compatible version of Docker Desktop (Preview) has been released to the public, so I will try it