Web development transition from MAMP to Docker

I'm new to Docker, and it's hard for me to apply its core technology in my current web development. Using MAMP, you just need to download the application, put the PHP / HTML files in / htdocs, start the servers, and then go to http: // localhost: 8888 / to see your web application. Now, using docker, I wonder how I can do the same. So far I have been extracting http, php and mysql images from the Docker Hub.

  1. How can I link these three images together to make them work? Or how can I run them at the same time?
  2. Where should I put / htdocs or how can I access it?
  3. MAMP has phpMyAdmin to access the database, is there something similar in Docker?

I work on Mac OS X Yosemite (10.10.1) with boot2docker v1.4.1 and VirtualBox 4.3.20.

+7
source share
3 answers
  • How to link these three images together to make them work? Or how do I run them at the same time?

Use fig to define and link containers.

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

It depends entirely on the configuration of your container. You can try PHP with Apache from DockerHub. See Documents for an explanation of where to put your files.

  1. MAMP has phpMyAdmin to access the database, does Docker have something like this?

Of course the Docker container;) look for the DockerHub

0
source

Now you can use docker-compose and the docker-compose.yml file to perform the same action as in fig.

Finding containers for each service and linking them together is not an easy thing. The docker-compose file from the raw github project (inserted below for posterity) is a good start so that all apache, php, and mysql services work with the docker-compose -f docker-compose.yml up .

 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] 

After you do this _ and put the entry for damp.dev 127.0.0.1 in your hosts file, everything you mount in ~ / wet / wet (from this second to the last line) will be placed in the htdocs of the docker container and processed on the channel.

dampness is just the first example I found while delving into how to copy MAMP with docker. The most important thing worth noting is that you can use docker-compose instead of fig . Compose is based directly on the code base of Fig and is backward compatible with applications of Fig.

+3
source

for development, you can try "devilbox", it's pretty easy to start with. The Dockerized PHP stack supports an unlimited number of projects for which vhosts, SSL certificates and DNS records are automatically generated. Email and popular development tools will also be at your service. No configuration is required, as everything is already pre-configured.

http://devilbox.org/

0
source

Source: https://habr.com/ru/post/1211055/


All Articles