# Docker

## Ray config

When developing using Docker, the Ray host should point to the internal IP of your Docker host by using 'host.docker.internal' in [the config file](/content/docs/php/vanilla-php/configuration/index.html).

```
<?php
// Save this in a file called "ray.php"

return [
    /*
     *  The host used to communicate with the Ray app.
     */
    'host' => 'host.docker.internal',

/*
     *  The port number used to communicate with the Ray app.
     */
    'port' => 23517,

/*
     *  Absolute base path for your sites or projects in Homestead, Vagrant, Docker, or another remote development server.
     */
    'remote_path' => '...',

/*
     *  Absolute base path for your sites or projects on your local computer where your IDE or code editor is running on.
     */
    'local_path' => '...',
];
```

To make sure that Ray uses the correct file path for creating the links, you will also need to set up the `remote_path` and `local_path` variables. `remote_path` is the absolute path of your project in the Docker container. `local_path` is the absolute path of your project on the local file system.

**Example:**
In your `docker-compose.yml` you mount the volume as follows:

```
volumes:
  - .:/var/www
```

Then `remote_path` should be `/var/www` and `local_path` should be the absolute path to the directory that you mount as `/var/www`, which is where your `docker-compose.yml` is located in the example (you can find this by running `pwd` inside that directory if you are on Linux).

## System config

Add `127.0.0.1  host.docker.internal` to `/etc/hosts` file.

On Linux, you will also need to add an 'extra_hosts' parameter to your PHP container definitions to expose 'host.docker.internal'. Please make sure you are using Docker `20.03` or higher. If you are using DDEV this is already taken care of.

```
#docker-compose.yml

services:
  site:
    image: nginx:stable-alpine
    container_name: nginx
    ports:
      - "80:80"
    depends_on:
      - php
      - db
    networks:
      - packt-api
    extra_hosts: # <-- does no harm
      - "host.docker.internal:host-gateway" # <-- does no harm

php:
    image: php:fpm-alpine
    …
    networks:
      - packt-api
    extra_hosts: # <--- this is required
      - "host.docker.internal:host-gateway" # <--- this is required
```

If you are using Lando, you can add this to your overrides:

```
services:
    appserver:
        overrides:
            extra_hosts:
                - "host.docker.internal:host-gateway"
```

## Firewall config

If it does not work after that, you could try to open your _GatewayPorts_ inside your ssh config.

Go to your SSH config:

```
nano /etc/hosts/sshd_config
```

Search for _GatewayPorts_ and set it from **no** to **yes**

```
GatewayPorts yes
```

If you're using UFW firewall you need to allow Ray's port:

```
sudo ufw allow in from any to 172.17.0.1/16 port 23517 comment 'Spatie Ray'
```

## Debug without breaking your flow

Ray keeps all your debug output neatly organized in a dedicated desktop app.

Download Ray

[Buy Ray for\ 49 USD](https://spatie.be/products/ray)

Licenses are valid for 1 year and managed through [Spatie](https://spatie.be/products/ray). Licenses purchased before Ray 3 remain valid. VAT is calculated at checkout.

## Thanks for trying out Ray!

macOS

[ARM](https://spatie.be/products/ray/v3/download/macos-arm64/latest) [Intel](https://spatie.be/products/ray/v3/download/macos-x64/latest)

Windows

[x86 (Intel)](https://spatie.be/products/ray/v3/download/windows/latest)

Linux

[AppImage](https://spatie.be/products/ray/v3/download/linux/latest)

By downloading Ray, you agree to our [terms of use](/content/terms-of-use/index.html).
