Now, from within the same directory, run the following docker-compose up -d Unexpected Xdebug Remote Host Behavior Users/larry/Sites//htdocs:/var/www/html You’ll want to change your volume location and IP address, of course. Create a docker-compose.yml file in your php71-apache directory with the contents below. Instead of a complicated run command as given above, we can store all the details in a docker-compose.yml file and use the docker-compose command to run the container instead of docker run . Your newly created container should be running and accessible at Using Docker Compose Finally, we tell Docker to use the php71-apache image we created in the build step above.You can manually place your IP address here. I use command substitution to grab my IP address from my Mac. In this case, we tell Xdebug the IP address to connect back to in other words, the IP of your machine where the debugger is listening. This allows us to pass any Xdebug parameters through the environment. Here, we’re setting the XDEBUG_CONFIG environment variable. The -e argument allows us to create environment variables used in the container.You can use port 80 on the host if you don’t have another web server running on your computer using that port. Next, the -p argument says that our host machine will listen for requests on port 8080 and forward those requests to port 80 of the container.The –v argument tells docker to mount a directory in our home directory called Sites//htdocs to the /var/.We’re going to call our container php71-apache-example with the –name argument.The -d argument says that the container is going to run in detached mode, meaning we don’t need to interact with it or keep it running in the foreground.First we tell docker that we want to run a container with the run sub-command.This is a little complicated so we’ll step through each bit. e XDEBUG_CONFIG="remote_host=$(ipconfig getifaddr en0)" Change the location of your website code as needed. Let’s spin her up! Here’s the command to do it. The -t argument specifies that our image will be named ‘php71-apache’. From within the php71-apache directory, run the following command. Now that our configuration is all set up, it’s time to build the image. Line 7: Allow access to the container’s port 80. Line 6: Copy the xdebug.ini file to the image. Line 5: (optional) Copy our php.ini file to the image. Line 4: Install the Xdebug extension via PECL. Line 3: We enable the rewrite Apache module because most of my projects need it. ![]() ![]() More information about installing PHP extensions in containers can be found on the PHP repository page for Docker under the How to install more PHP extensions section. Line 2: Runs a script that will install the mysqli PHP extension. Line 1: Specifies the base image from which we’re building our custom image. FROM php:7.1-apacheĬOPY xdebug.ini /usr/local/etc/php/conf.d Let’s move on to creating our Dockerfile . Now that our configuration files are complete. The second configuration file is for Xdebug. This one-liner will keep PHP from complaining about setting a time-zone. Let’s create a directory where we’ll store the files that we’re creating. Some familiarity with the command line is assumed. If you don’t already have it installed, get Docker for your platform here. This article walks through setting up Xdebug on a Docker container running Apache with PHP 7.1.
0 Comments
Leave a Reply. |