Web development transition from MAMP to Docker
Asked Answered
M

2

11

I am new to Docker and I am having a hard time applying its core technology to my present web development. Using MAMP, you just need to download the app, put your PHP/HTML files on /htdocs, start servers, then go to http://localhost:8888/ to see your webapp. Now, using docker, I’m wondering how can I do the same. What I’ve done so far is to pull http, php and mysql images from the Docker Hub.

  1. How can I link these three images together to make them work? Or How should I run them simultaneously?
  2. Where should I put the /htdocs or how can I access it?
  3. MAMP has a phpMyAdmin for database access, does Docker has something like this?

I’m working on a Mac OS X Yosemite (10.10.1) with boot2docker v1.4.1 and VirtualBox 4.3.20.

Mayfair answered 14/1, 2015 at 8:21 Comment(0)
R
0
  1. How can I link these three images together to make them work? Or How should I run them simultaneously?

Use fig to define and link containers.

  1. Where should I put the /htdocs or how can I access it?

This depends solely on your container configuration. You may try PHP with Apache from DockerHub. See the docs for an explanation where to put your files.

  1. MAMP has a phpMyAdmin for database access, does Docker has something like this?

Sure, a Docker container ;) search DockerHub

Redskin answered 22/1, 2015 at 23:49 Comment(1)
addon: I am working on a PHP application template which could give you some ideas, it also runs locally with XAMP & co.Redskin
V
7

You can now use docker-compose and a docker-compose.yml file to accomplish the same thing as fig.

Finding containers for each service and linking them together isn't the easiest thing. The docker-compose file from The damp github project (pasted below for posterity) is a good start for how to get the apache, php, and mysql services all running with a docker-compose -f docker-compose.yml up command.

proxy:
    image: jwilder/nginx-proxy
    ports: ['80:80']
    volumes: ['/var/run/docker.sock:/tmp/docker.sock:ro']
    environment: [DEFAULT_HOST=damp.dev]
database:
    image: 'mysql:5.7'
    ports: ['3306:3306']
    environment: [MYSQL_ROOT_PASSWORD=password]
phpmyadmin:
    image: corbinu/docker-phpmyadmin
    links: ['database:mysql']
    environment: [MYSQL_USERNAME=root, MYSQL_ROOT_PASSWORD=password, VIRTUAL_HOST=phpmyadmin.damp.dev]
damp:
    image: httpd
    volumes: ['~/damp/damp:/usr/local/apache2/htdocs']
    environment: [VIRTUAL_HOST=damp.dev]

Once you do that _and put an entry for damp.dev 127.0.0.1 in your hosts file, anything you mount in ~/damp/damp (per that second to last line) will be put in the htdocs of the docker container and served up on damp.dev/[whatever].

damp is just the first example I found poking around on how to replicate MAMP with docker. The most important thing to note is that you can use docker-compose instead of fig. Compose is based directly on the Fig codebase and is backwards-compatible with Fig applications.

Viscountess answered 29/3, 2017 at 2:38 Comment(0)
R
0
  1. How can I link these three images together to make them work? Or How should I run them simultaneously?

Use fig to define and link containers.

  1. Where should I put the /htdocs or how can I access it?

This depends solely on your container configuration. You may try PHP with Apache from DockerHub. See the docs for an explanation where to put your files.

  1. MAMP has a phpMyAdmin for database access, does Docker has something like this?

Sure, a Docker container ;) search DockerHub

Redskin answered 22/1, 2015 at 23:49 Comment(1)
addon: I am working on a PHP application template which could give you some ideas, it also runs locally with XAMP & co.Redskin

© 2022 - 2024 — McMap. All rights reserved.