Setting up a development enviroment in Docker

Hi Everyone,

I am slowly switching from Xampp (on my Windows machine, home projects) to Docker, at least I want to.

Now I have to admit that I don’t use my Windows laptop much for writing code, as I have a MacBook Pro where I develop within Vagrant for a really big project.

In addition to this large project, I also want to pick up smaller projects that need their environment. Now it is a bit overkill to throw a whole vagrant box at this if we do set up a new environment for these kinds of projects.

On the website http://geekyplatypus.com/dockerise-your-php-application-with-nginx-and-php7-fpm/, I came across a tutorial about docker and its use as development.

On the website, they have this docker-compose.yml file:

web:
    image: nginx:latest
    ports:
        - "8080:80"
    volumes:
        - ./code:/code
        - ./site.conf:/etc/nginx/conf.d/site.conf
    links:
        - php
php:
    image: php:7-fpm
    volumes:
        - ./code:/code

Which mount the code folder in your current directory (besides the site.conf file, that is also in nginx).

What’s the best way to run composer here. Nginx mounts the code directory and passes it back to PHPfpm?

In addition, what is the best approach to run different applications (different docker containers?)

docker-compose up -d is pretty much the default here.

No, NGiNX and PHP-FPM both mount the same directory under the same path, so that when NGiNX tells PHP-FPM to "please run the script at path /code/blah/blah/blah.php` they’re both referring to the same thing.

Yes, one docker setup per project. If you want to run multiple projects at the same time you can use a proxy in front of it, like Traefik.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.