Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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/>";
@SamuraiPetrus

This comment has been minimized.

Copy link

@SamuraiPetrus SamuraiPetrus 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