re: What do you use to replicate your dev environment? VIEW POST

TOP OF THREAD FULL DISCUSSION
re: For years, I used a messy MAMP setup. All my projects were several sub-directories down from the root htdocs folder. A few months ago, I took the t...
 

Could you tell me more about your setup and how you learned Docker? I currently have a messy MAMP setup myself.

 

Sure! Anything specific you'd like to know?

My setup used to look like this:

/Applications/MAMP/
    htdocs/
        other/ # Here I'd have anything that just needed to be on a web server.
            forest-theme/ # Here's a sub-installation of WordPress for my portfolio theme.
            word-search/
            # etc.
        wp-content/
            plugins/ # Build/deployment scripts sat in the root of the plugins folder.
                necessary-tools/
            themes/
            # etc.
    logs/
        php/
            error.log # Yep...one PHP error log for all my sites. o.0
~/Documents/Programming/ # Here i'd have everything else that wasn't in need of a web 
                         # server.

Now, it looks like this:

~/Code/
    # Projects are organized by language/platform. I omitted most of it. There's a lot.
    docker/
        _dockerc-repos/ # Contains reusable custom Docker Compose files.
        other-web/
            word-search/
                docker-compose.yml # Just a simple apache server here.
                html/
            # etc.
        wordpress/
            necessary-tools/
                docker-compose.yml # Custom WordPress setup with PHP, WP-CLI, and MySQL.
                Dockerfile
                logs/         # All these volumes are mounted to the docker container, to
                mysql/        # maintain state.
                plugins/      #
                themes/       #
                wp-admin/     #
                wp-includes/  #
                wp-config.php #
                # etc.
            forest-theme/
            # etc.
    Wordpress/ # Only contains SVN repositories for my plugins on the WordPress plugin
               # directory.

I learned via trial and error. Installing Docker itself is straightforward. I think the most confusing part was understanding the capabilities of the Docker containers. That and the commands. Quite a few tutorials that I found used the docker run command which requires the manual entry of arguments every time you want to turn on a docker container. Once I found Docker Compose, it was much easier.

Docker compose lets you set all your configurations ahead of time in a docker-compose.yml file (the documentation for Docker Compose isn't bad either). Then, all you have to do is run the docker-compose up command to fire up a container and docker-compose down to bring it down.

Sweet setup! I'm still new to Wordpress actually, do you have a Docker container for each Wordpress project you have or are they all on the same and you have maybe one container by type of project ?

If you have one per Worpress project, that should take up a lot of disk space, right?

Thanks!

Yes, I have a Docker container for every project. My Docker workspace (including everything) is 3.2G, and my WordPress workspace takes up 2.2G of that. So, it doesn't take up much space.

That's actually not that bad, I'll give it a shot. Thanks!

Quick question if you don't mind, do you use a tool in particular when you mount your directories to the container, or do you just use the -v command ?

I use docker-compose which allows you to set up docker container configurations in a docker-compose.yml file. Volume mounting is described in the docker-compose file documentation.

It's an alternative to using the base docker command and using -v every time. I don't like having to remember what options I used for a custom docker container, so for me, slapping it into a config file and running docker-compose up or docker-compose down is a huge benefit.

code of conduct - report abuse