Install WordPress with Docker Compose on Windows Server 2019/2022

Install WordPress dengan Docker Compose di Windows Server 2019/2022

Pastikan sudah install Docker Desktop, cek disini


  • Buka PowerShell, pastikan docker engine sudah aktif dan Switch to Linux Containers…
  • Buat folder: wordpress_sys-ops
  • Masuk ke folder cd wordpress_sys-ops
  • Buat file docker-compose.yml
  • Edit file docker-compose.yml dengan notepad
PS C:\Users\Administrator> md wordpress_sys-ops

    Directory: C:\Users\Administrator

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         5/31/2022  12:44 PM                wordpress_sys-ops

PS C:\Users\Administrator> cd wordpress_sys-ops
PS C:\Users\Administrator\wordpress_sys-ops> New-Item docker-compose.yml

    Directory: C:\Users\Administrator\wordpress_sys-ops

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----         5/31/2022  12:44 PM              0 docker-compose.yml

PS C:\Users\Administrator\wordpress_sys-ops> notepad docker-compose.yml
  • Isi file docker-compose.yml
  • nama container database: sys-ops_db , menggunakan image mysql:8.0
  • nama container wordpress: sys-ops_wp , menggunakan image wordpress:latest , dengan external port 8001
version: '3.0'
services:
  sys-ops_db:
    image: mysql:8.0
    volumes:
      - ./sys-ops_db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_DATABASE: db_wp
      MYSQL_USER: user_wp
      MYSQL_PASSWORD: pass_wp
      MYSQL_ROOT_PASSWORD: pass_root
  sys-ops_wp:
    depends_on:
      - sys-ops_db
    image: wordpress:latest
    volumes:
      - ./sys-ops_wp_files:/var/www/html
    ports:
      - "8001:80"
    restart: always
    environment:
      WORDPRESS_DB_HOST: sys-ops_db:3306
      WORDPRESS_DB_USER: user_wp
      WORDPRESS_DB_PASSWORD: pass_wp
      WORDPRESS_DB_NAME: db_wp
volumes:
  sys-ops_db_data:
  sys-ops_wp_files:
  • Jalankan docker-compose
PS C:\Users\Administrator\wordpress_sys-ops> docker-compose up -d

[+] Running 35/35
 - sys-ops_wp Pulled                                             49.8s
   - 42c077c10790 Pull complete                                  13.7s
   - 8934009a9160 Pull complete                                  13.8s
   - 5357ac116991 Pull complete                                  28.8s
 - sys-ops_db Pulled                                             33.7s
   - c1ad9731b2c7 Pull complete                                  4.3s
   - 54f6eb0ee84d Pull complete                                  4.5s
   - cffcf8691bc5 Pull complete                                  4.8s
[+] Running 3/3
 - Network wordpress_sys-ops_default         Created             0.1s
 - Container wordpress_sys-ops-sys-ops_db-1  Started             9.5s
 - Container wordpress_sys-ops-sys-ops_wp-1  Started             6.7s
  • Saat menjalankan docker-compose, akan muncul notifikasi di pojok kanan bawah (notification try) seperti berikut: klik Share It
  • Cek status container
PS C:\Users\Administrator\wordpress_sys-ops> docker ps -a

CONTAINER ID   IMAGE              COMMAND                  CREATED          STATUS          PORTS                  NAMES
95a1e651d9c3   wordpress:latest   "docker-entrypoint.s…"   11 minutes ago   Up 11 minutes   0.0.0.0:8001->80/tcp   wordpress_sys-ops-sys-ops_wp-1
f979e30194a6   mysql:8.0          "docker-entrypoint.s…"   11 minutes ago   Up 11 minutes   3306/tcp, 33060/tcp    wordpress_sys-ops-sys-ops_db-1
  • Akses wordpress lewat browser dengan url: http://ip_address_windows:8001 , pastikan port 8001 sudah di allow di windows firewall atau disable windows firewall

herdiana3389

A system administrator with skills in system administration, virtualization, linux, windows, networking, cloud computing, container, etc.