Code Monkey home page Code Monkey logo

docker-for-local-development's Introduction

Docker for Building a Local Development Environment

This project provides a basic Docker setup, for building a local development environment for Zend Expressive, and other PHP, application development.

Why?

Why? Good question. But easy to answer. The intent is to provide a starting point for developers to get up and running quickly, using Docker, to build a local development environment. If you’d like much more background as to why, checkout this tutorial on Master Zend Framework. It lays out, much more comprehensively, the reasons why this is a good thing to do.

Installation

To get up and running, after cloning the repository:

  1. Install Docker. If you’re running a Linux distribution, use its package manager. If you’re using either macOS or Windows, download the respective Docker package installers: Docker for Mac or Docker for Windows.

  2. Add the cloned files to the root of a Zend Expressive (or other PHP) project.

  3. In docker/nginx/default.conf change the default document root setting, root /PATH/TO/YOUR/DOCUMENT/ROOT;, to suit your installation. More than likely, there will be a public/ directory in your source. So change the setting to be root /var/www/html/public;.

  4. Build the configuration by running: docker-compose up -d.

Check That Everything Is Working

To check that the build is working, run docker-compose ps. This should give you output similar to the below.

               Name                             Command             State               Ports
---------------------------------------------------------------------------------------------------------
dockerforlocaldevelopment_mysql_1     docker-entrypoint.sh mysqld   Up      3306/tcp
dockerforlocaldevelopment_nginx_1     nginx -g daemon off;          Up      443/tcp, 0.0.0.0:8080->80/tcp
dockerforlocaldevelopment_php_1       php-fpm                       Up      9000/tcp
dockerforlocaldevelopment_testing_1   php-fpm                       Up      9000/tcp

If you’d like to see more detailed information, check the log file by running docker-compose logs. To check that the files are inside the container, run the following command, substituting dockerforlocaldevelopment to match your directory name:

docker exec -it dockerforlocaldevelopment_nginx_1 ls -lahrt /var/www/html

Contributing

See the CONTRIBUTING file.

License

This project is licensed under the MIT License.

docker-for-local-development's People

Contributors

maltblue avatar mblkita avatar rawkode avatar settermjd avatar swoldanski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-for-local-development's Issues

Directory Index fails

2016/12/29 18:24:16 [error] 7#7: *1 directory index of "/var/www/html/" is forbidden, client: 172.18.0.1, server: , request: "GET / HTTP/1.1", host: "localhost:8080"

Is Step 2 mandatory ?

Do we really need to put all of the cloned files in the root of the php application ? Is there another way ? I'm looking for a way to include a php directory that is located elsewhere on my computer.

Simple way to map localhost:8080 to a custom hostname?

I am using this and it generally works well! However rather than use http://localhost:8080 to access the container in the browser i'd like to use a custom hostname e.g docker.backend - how is the best way to achieve this? I have tried modifying the nginx/default.conf file to include the server_name but have had no luck with this :(

Cannot start service nginx, mount caused "not a directory" [Win10 / virtualbox]

When cloning this repo and running it on a Windows machine (Windows 10 home / Virtual Box / Docker toolbox), Powershell will return the errror:

ERROR: for nginx  Cannot start service nginx: invalid header field value "oci runtime error: container_linux.go:247: sta
rting container process caused \"process_linux.go:359: container init caused \\\"rootfs_linux.go:53: mounting "/d
/www/dockertest2/docker/nginx/default.conf" to rootfs "/mnt/sda1/var/lib/docker/aufs/mnt/2bb556ad246980ee4
99d09d07b3e8fa290014cae1f723117652c796964f851c3" at "/mnt/sda1/var/lib/docker/aufs/mnt/2bb556ad246980ee499
d09d07b3e8fa290014cae1f723117652c796964f851c3/etc/nginx/conf.d/default.conf" caused "not a directory"

(I came to this repo through this tutorial, so I am super new to Docker.) If I were to guess, I'd say it's looking to mount the file from the docker machine rather than the Windows host. But I'm not experienced enough with Docker to make any headway with it.

I'm using docker-compose 1.8.1, build 004ddae

File not found.

Following your tutorial on an windows 7 pc running docker.
Thank you for writing it!
I get a "File not found." message with the following output.
A index.php file is in the root of the project folder.

[NGINX]
2016/11/17 21:18:58 [error] 5#5: *7 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 192.168.99.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://172.20.0.2:9000", host: "192.168.99.100:8080"
192.168.99.1 - - [17/Nov/2016:21:18:58 +0000] "GET / HTTP/1.1" 404 27 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36"

[PHP]
172.20.0.4 - 17/Nov/2016:21:18:58 +0000 "GET /index.php" 404

Any idea?
Thank you.

Cannot create container for service php: An error occured while sharing drive

When I run the command docker-compose up -d I get this error :

ERROR: for php Cannot create container for service php: An error occured while sharing drive
ERROR: Encountered errors while bringing up the project.

I tried many ways to solve but the problem persists, so if you have any idea how is this about, I will be thankful.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.