Notification texts go here Contact Us Buy Now!

Cara Menjalankan File PHP Menggunakan Docker Compose



Di artikel sebelumnya kita telah membahas cara menginstal docker engine dan docker compose, untuk melanjutkan tutorial yang ini sialahkan terlebih dahulu menginstal keduanya yaitu docker compose dan docker engine.

Untuk struktur file yang akan kita buat kurang lebih seperti di bawah ini.
├── docker-compose.yml
└── php
    └── index.php
Setelah kamu mengetahui strukturnya kemudian kita akan mencoba membuat scriptnya, script yang pertama yang kita buat ialah docker-compose.yml ini merupakan file yang berfungsi untuk menjalankan script yang akan kita buat tadi menggukan perintah docker-compose up -d.
# ./docker-compose.yml

version: '3'

services:
  db:
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: my_secret_pw_shh
      MYSQL_DATABASE: test_db
      MYSQL_USER: devuser
      MYSQL_PASSWORD: devpass
    ports:
      - "9906:3306"
  web:
    image: php:7.2.2-apache
    container_name: php_web
    depends_on:
      - db
    volumes:
      - ./php/:/var/www/html/
    ports:
      - "8100:80"
    stdin_open: true
    tty: true
Berikutnya kita akan membuat file php di dalam folder php dengan nama index.php.
<!-- ./php/index.php -->

<html>
    <head>
        <title>Hello World</title>
    </head>

    <body>
        <?php
            echo "Hello, World!";
        ?>
    </body>
</html>
Setelah itu jalankan filenya docker-compose up -d dan buka di browser http://localhost:8100/ .
db mysql://devuser:devpass@localhost:9906/test_db.


Getting Info...

About the Author

IT Enthusiast

Posting Komentar

Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.