Skip to content

Instantly share code, notes, and snippets.

@fernandodebrando
Created July 10, 2016 03:54
Show Gist options
  • Save fernandodebrando/cdb5e2a8ea5aee18f74addf89baefbb1 to your computer and use it in GitHub Desktop.
Save fernandodebrando/cdb5e2a8ea5aee18f74addf89baefbb1 to your computer and use it in GitHub Desktop.
Criando um ambiente de desenvolvimento PHP com Docker Compose
php:
build: ./Dockerfile
ports:
- "81:81"
- "443:443"
volumes:
- ./www:/var/www/html
links:
- db
db:
image: mysql:5.7
volumes:
- /var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=phprs
- MYSQL_DATABASE=phprs
FROM php:5.6-apache
RUN docker-php-ext-install mysqli
<?php
echo "<pre><h2>Criando um ambiente de desenvolvimento PHP com Docker Compose.</h2></pre><br/>";
mysqli_connect("db", "root", "phprs") or die(mysqli_error());
echo "<pre><h3>Connected to MySQL<h3></pre><br/>";
@petrusnog
Copy link

petrusnog commented Mar 4, 2021

Para adicionar uma interface gráfica para gerenciamento do banco de dados (o famoso "phpmyadmin"), basta adicionar as seguintes linhas ao seu docker-compose.yml:

phpmyadmin:
  image: phpmyadmin/phpmyadmin
  links:
    - db:db
  ports:
    - "8002:80"
  environment:
    - MYSQL_ROOT_PASSWORD=phprs

e rodar o comando:

 docker-compose up -d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment