Categories
wordpress

WordPress u Docker-u

Podrazumeva se da na računaru imamo instaliran funkcionalan Docker.

Najpre kreiramo direktorijum za naš projekat. U tom direktorijumu kreiramo fajl docker-compose.yml sa sledećim sadržajem:

version: '3.3'
services:
    db:
        image: mysql:5.7
        volumes:
            - db_data:/var/lib/mysql
        restart: always
        environment:
            MYSQL_ROOT_PASSWORD: secret
            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
            WORDPRESS_DB_NAME: wordpress
volumes:
    db_data: {}

Zatim sledi pokretanje kontejnera:

docker-compose up -d

Sada u brauzeru možemo da otvorimo adresu http://localhost:8000 i da instaliramo WordPress.

Ako želimo da pristupimo WordPress instalaciji, kucamo:

docker-compose exec wordpress bash

Ako želimo da pristupimo bazi podataka, kucamo:

docker-compose exec db bash
mysql wordpress -u wordpress -p

Izvor: Hostinger