0

I have an issue reaching my local machine from a docker container. It is created with Laravel sail like this:

laravel.test:
        build:
            context: ./vendor/laravel/sail/runtimes/8.1
            dockerfile: Dockerfile
            args:
                WWWGROUP: '${WWWGROUP}'
        image: sail-8.1/app
        extra_hosts:
            - 'host.docker.internal:host-gateway'
        ports:
            - '${APP_PORT:-80}:80'
        environment:
            WWWUSER: '${WWWUSER}'
            LARAVEL_SAIL: 1
            XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
            XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
        volumes:
            - '.:/var/www/html'
        networks:
            - sail
        depends_on:
            - mysql
            - redis
            - meilisearch
            - selenium

And this is the network config:

networks:
    sail:
        driver: bridge

When I login to the container: docker-compose exec laravel.test sh

And run: curl host.docker.internal I get a response.

But like this: curl host.docker.internal:8000 I get: curl: (7) Failed to connect to host.docker.internal port 8000: Connection refused.

How do I have port forwarding while connecting to my local maching?

I seen I should use "host" as the driver for the network, but that doesn't work at all.

Result of docker ps

9e6716ad920e   sail-8.1/app                  "start-container"        3 hours ago   Up 3 hours             8000/tcp, 0.0.0.0:8080->80/tcp, :::8080->80/tcp                                        integrationproxy_laravel.test_1
a2e8e4b31536   selenium/standalone-chrome    "/opt/bin/entry_poin…"   3 hours ago   Up 3 hours             4444/tcp, 5900/tcp                                                                     integrationproxy_selenium_1
874d8b620bb4   mysql/mysql-server:8.0        "/entrypoint.sh mysq…"   3 hours ago   Up 3 hours (healthy)   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060-33061/tcp                             integrationproxy_mysql_1
5bdcd577ac54   redis:alpine                  "docker-entrypoint.s…"   3 hours ago   Up 3 hours (healthy)   0.0.0.0:6379->6379/tcp, :::6379->6379/tcp                                              integrationproxy_redis_1
878eb11c9a13   getmeili/meilisearch:latest   "tini -- /bin/sh -c …"   3 hours ago   Up 3 hours (healthy)   0.0.0.0:7700->7700/tcp, :::7700->7700/tcp                                              integrationproxy_meilisearch_1
a94a0ccf3741   mailhog/mailhog:latest        "MailHog"                3 hours ago   Up 3 hours             0.0.0.0:1025->1025/tcp, :::1025->1025/tcp, 0.0.0.0:8025->8025/tcp, :::8025->8025/tcp   integrationproxy_mailhog_1

Dion Snoeijen
  • 143
  • 2
  • 9

0 Answers0