Skip to content

Instantly share code, notes, and snippets.

@leny
Created February 18, 2020 13:40
Show Gist options
  • Save leny/91f5c543d12fed4e266ee05ef7b1ccfa to your computer and use it in GitHub Desktop.
Save leny/91f5c543d12fed4e266ee05ef7b1ccfa to your computer and use it in GitHub Desktop.

DEV env: docker-compose

This is a generated README by the BeCode CLI tool.

If you are completely new to Docker we recommend you to read the Docker Survival Guide.

Run docker

When starting your env for the first time, run the following command in yhour repo:

docker-compose build

NOTE: thus you don't need to run this command each time, it may be useful to rebuild your services when you change the configuration of your services.

Then, simply run the following command to get started:

docker-compose up

The details for all your services is detailed bellow.

Your services

Langage: PHP

What is PHP?

PHP is a server-side scripting language designed for web development, but which can also be used as a general-purpose programming language. PHP can be added to straight HTML or it can be used with a variety of templating engines and web frameworks. PHP code is usually processed by an interpreter, which is either implemented as a native module on the web-server or as a common gateway interface (CGI).

Container

Usage

Place your PHP files in ./src folder, access it with your browser at address localhost.


Database: MariaDB

What is MariaDB?

MariaDB is a community-developed fork of MySQL intended to remain free under the GNU GPL.

Container

Usage

NOTE: from dev POV, using MariaDB is strictly the same as using MySQL.

IMPORTANT: the first startup of this container is long : the db server needs to be initialized.

NOTE: the container don't create a database at startup - create it within your code (or with phpMyAdmin)

Access from another container

You can access the database from another container with the following informations:

  • host: mysql
  • port: 3306
  • user: root
  • pass: root
Access from your host

You can access the database from you host with the following informations:

  • host: localhost
  • port: 3306
  • user: root
  • pass: root

Tools: phpMyAdmin

What is phpMyAdmin?

A web interface for MySQL and MariaDB.

Container

Usage

The container is already configured to use the MySQL/MariaDB credentials.
Access phpMyAdmin with your browser at address localhost:8001.

---
version: "3"
services:
php:
image: "becodeorg/php"
volumes:
- "./src:/var/www/html"
ports:
- "80:80"
mysql:
image: "mariadb"
restart: "unless-stopped"
volumes:
- "mysql_db:/var/lib/mysql"
ports:
- "3306:3306"
- "33060:33060"
environment:
MYSQL_ROOT_PASSWORD: "root"
phpmyadmin:
image: "phpmyadmin/phpmyadmin"
ports:
- "8001:80"
depends_on:
- "mysql"
environment:
PMA_HOST: "mysql"
PMA_USER: "root"
PMA_PASSWORD: "root"
volumes:
mysql_db:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment