nedeľa 30. júla 2023

How to install wordpress via docker?

 How to install wordpress via docker?



 

1) first: docker terminology

What is docker?

Docker is the PAAS product of containers.  https://en.wikipedia.org/wiki/Docker_(software)

- if we have containers, how we install wordpress?

And what is the container?

- first point is docker image

docker image is the image where is install operating system and som "application"

for exapmle wordpress:

if we install wordpress - we download some Debian 11 and in this operating system is installed wordpress (you know www server, php, etc)

- second point: what is container?

from docker image we build docker container

- you know: wordpress for production, wordpress for test, wordpress for development, etc.

2) don't be scare: I asked AI BARD for help:

BARD's help;

A) install docker - we had it

B) install docker-compose -

(I installed via this https://wiki.crowncloud.net/?How_to_Install_Docker_Compose_on_AlmaLinux_9 )

docker compose is tool for defining and running multi-container:

https://docs.docker.com/compose/ - very useful

C) add docker-compose file:

docker-compose.yml

version: '3'

services:
  wordpress:
    image: wordpress:latest
    ports:
      - 8080:80
    volumes:
      - ./wp-content:/var/www/html
  db:
    image: mysql:latest
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: password
    volumes:
      - ./mysql:/var/lib/mysql


- this file download latest image wordpress; create 2 containers:

first container wordpress (which will be running on port 8080)       

second container: - in this container is installed mysql server

3) WORDPRESS BASE

- as you know wordpres is writing in PHP (installed in first container), use http apache (install in second container) and use mysql server for "data store" (second container )

- in wordpress we have configuration file wp-config.php

- in wp-config.php you fill what you see in docker-compose.yml (the name of database, etc)

- BUT YOU HAVE TO change database host because it is not install in first container - you gave the ip address of second container

4) docker network

docker images ls

docker ps

docker network ls

-- try these commands:

- docker network ls - in this command you don't see IP address  

- we need the use: docker inspect command

via this:

docker inspect 5c117602c67a | grep "IPAddress"

- docker inspect IDcontainer (you see at docker ps command)

--> after that you open wp-config.php and add the IP address 172.18.0.2 (in my case, you have the diffrent IP )

--> go to firefox and gave: IP your linux machine (in my case 10.233.13.13:8080) - and in this IP there is and wordpress



     

Žiadne komentáre:

Zverejnenie komentára