Failed UDP connection in Docker container - php

I am working on a laravel php application which seemed to running fine until I stopped working for the day by running the docker-compose down command. When I got back to working again by starting the container docker-compose up -d, the container started throwing a failed connecting to udp error. Below is the error I am getting
In my logs I can see some message
[2022-09-07 07:25:09] local.ERROR: Failed connecting to udp://: (0: Failed to parse address ":") {"exception":"[object] (UnexpectedValueException(code: 0): Failed connecting to udp://: (0: Failed to parse address ":") at /var/www/html/vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php:313)
Because of the error php exits and I can do practically nothing with the app at this point. Does anyone know how I can deal with the issue and get php state back to running?
Below is my docker file
# For more information: https://laravel.com/docs/sail
version: '3'
services:
gateway:
build:
context: services/vendor/laravel/sail/runtimes/7.4
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP}'
image: sail-7.4/app
extra_hosts:
- 'host.docker.internal:host-gateway'
ports:
- '8000:80'
- '${VITE_PORT:-5173}:${VITE_PORT:-5173}'
environment:
WWWUSER: '${WWWUSER}'
LARAVEL_SAIL: 1
XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
volumes:
- './gateway:/var/www/html'
networks:
- sail
depends_on:
- db1
- redis
- mailhog
services:
build:
context: servvices/vendor/laravel/sail/runtimes/8.1
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP}'
image: sail-8.1/app
extra_hosts:
- 'host.docker.internal:host-gateway'
ports:
- '8002:80'
- '${VITE_PORT:-5175}:${VITE_PORT:-5173}'
environment:
WWWUSER: '${WWWUSER}'
LARAVEL_SAIL: 1
XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
volumes:
- './loans:/var/www/html'
networks:
- sail
depends_on:
- gateway
- db2
# gateway db
db1:
image: 'mysql/mysql-server:8.0'
ports:
- '${FORWARD_DB_PORT:-3306}:3306'
environment:
MYSQL_ROOT_PASSWORD: '${GATEWAY_DB_PASSWORD}'
MYSQL_ROOT_HOST: "%"
MYSQL_DATABASE: '${GATEWAY_DB_DATABASE}'
MYSQL_USER: '${GATEWAY_DB_USERNAME}'
MYSQL_PASSWORD: '${GATEWAY_DB_PASSWORD}'
MYSQL_ALLOW_EMPTY_PASSWORD: 1
volumes:
- 'spg_db:/var/lib/mysql'
- './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh'
networks:
- sail
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-p${GATEWAY_DB_PASSWORD}"]
retries: 3
timeout: 5s
# service db
db2:
image: 'mysql/mysql-server:8.0'
ports:
- '3308:3306'
environment:
MYSQL_ROOT_PASSWORD: '${SERVICE_DB_PASSWORD}'
MYSQL_ROOT_HOST: "%"
MYSQL_DATABASE: '${SERVICE_DB_DATABASE}'
MYSQL_USER: '${SERVICE_DB_USERNAME}'
MYSQL_PASSWORD: '${SERVICE_DB_PASSWORD}'
MYSQL_ALLOW_EMPTY_PASSWORD: 1
volumes:
- 'spl_db:/var/lib/mysql'
- './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh'
networks:
- sail
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-p${SERVICE_DB_PASSWORD}"]
retries: 3
timeout: 5s
redis:
image: 'redis:alpine'
ports:
- '${FORWARD_REDIS_PORT}:6379'
volumes:
- 'redis:/data'
networks:
- sail
healthcheck:
test: ["CMD", "redis-cli", "ping"]
retries: 3
timeout: 5s
mailhog:
image: 'mailhog/mailhog:latest'
ports:
- '${FORWARD_MAILHOG_PORT:-1025}:1025'
- '${FORWARD_MAILHOG_DASHBOARD_PORT:-8025}:8025'
networks:
- sail
networks:
sail:
driver: bridge
volumes:
db1:
driver: local
db2:
driver: local
redis:
driver: local

Related

environment problem in yml file for docker

i make an error on the point youmas:
environment:
XDEBUG_CONFIG: remote_host=172.17.0.1 remote_port=9000 remote_enable=1
networks:
- youmas
but i dont know how to fix them
version: "3"
services:
#PHP
youmas-app:
build:
context: .
dockerfile: Dockerfile
args:
- WITH_XDEBUG=true
image: youmas-app
container_name: youmas-app
restart: unless-stopped
tty: true
environment:
SERVICE_NAME: app
SERVICE_TAGS:
dev
# If you down want to use xDebug, set remote_enable=0
PHP_IDE_CONFIG: "serverName=Docker"
XDEBUG_CONFIG: remote_host=192.168.178.33 remote_port=9001
working_dir: /var/www
volumes:
- ./:/var/www
- ./docker/production/php/local.ini:/usr/local/etc/php/conf.d/local.ini
youmas:
environment:
XDEBUG_CONFIG: remote_host=172.17.0.1 remote_port=9000 remote_enable=1
networks:
- youmas
#Nginx
youmas-webserver:
build:
context: .
dockerfile: "./docker/production/nginx/Dockerfile"
container_name: youmas-webserver
restart: unless-stopped
tty: true
ports:
- "80:80"
- "443:443"
volumes:
- ./:/var/www
- ./docker/production/nginx/conf.d/:/etc/nginx/conf.d/
- ./docker/production/certbot/conf:/etc/letsencrypt
- ./docker/production/certbot/www:/var/www/certbot
networks:
- youmas
command: '/bin/sh -c ''while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g "daemon off;"'''
# Certbot SSL
certbot:
image: certbot/certbot
volumes:
- ./docker/production/certbot/conf:/etc/letsencrypt
- ./docker/production/certbot/www:/var/www/certbot
entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
#MySQL
youmas-database:
image: mysql:5.7.22
container_name: youmas-database
restart: unless-stopped
tty: true
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: youmas
MYSQL_ROOT_PASSWORD: K4#|ahdpof8##!~
SERVICE_TAGS: dev
SERVICE_NAME: mysql
volumes:
- dbdata:/var/lib/mysql/
- ./docker/production/mysql/my.cnf:/etc/mysql/my.cnf
networks:
- youmas
#PHP My Admin
youmas-phpmyadmin:
image: phpmyadmin/phpmyadmin
ports:
- "7000:80"
links:
- youmas-database:youmas-database
environment:
MYSQL_USER: root
MYSQL_PASSWORD: codeverze
MYSQL_ROOT_PASSWORD: codeverze
networks:
- youmas
#Networks
networks:
youmas:
driver: bridge
#Volumes
volumes:
dbdata:
driver: local
any solution?
Your Syntax is wrong,
Replace the environment section to look like this :
youmas-app:
build:
context: .
...
...
...
environment:
- 'SERVICE_NAME=app'
- 'SERVICE_TAGS=dev'
...
...

Laravel 8 install - sail up hangs at mailhog/meilisearch - no phpmyadmin if ctrl-c

I have installed a clean Monterey on my Mac and now Laravel 9. I followed the instruction in the docs but [sail up] does not stop to throw lines after lines in termional. I saw in a similar post that this was normal. So I exit with ctrl-c. In Docker Desktop, the container example-app is there but what is the next step?
I see that the docker-compose.yml file does not have phpMyAdmin. Was it installed? Where is it? How do I access it? Before Monterey, I installed Laravel 8 with brew and composer and I could access it with pma.test in the browser...
Also how do I access the project in the browser? I used to type example-app.test to view it...
I need help to figure out the next steps.
docker-composere.yml
# For more information: https://laravel.com/docs/sail
version: '3'
services:
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
mysql:
image: 'mysql/mysql-server:8.0'
ports:
- '${FORWARD_DB_PORT:-3306}:3306'
environment:
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
MYSQL_ROOT_HOST: "%"
MYSQL_DATABASE: '${DB_DATABASE}'
MYSQL_USER: '${DB_USERNAME}'
MYSQL_PASSWORD: '${DB_PASSWORD}'
MYSQL_ALLOW_EMPTY_PASSWORD: 1
volumes:
- 'sail-mysql:/var/lib/mysql'
networks:
- sail
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-p${DB_PASSWORD}"]
retries: 3
timeout: 5s
redis:
image: 'redis:alpine'
ports:
- '${FORWARD_REDIS_PORT:-6379}:6379'
volumes:
- 'sail-redis:/data'
networks:
- sail
healthcheck:
test: ["CMD", "redis-cli", "ping"]
retries: 3
timeout: 5s
meilisearch:
image: 'getmeili/meilisearch:latest'
ports:
- '${FORWARD_MEILISEARCH_PORT:-7700}:7700'
volumes:
- 'sail-meilisearch:/data.ms'
networks:
- sail
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--spider", "http://localhost:7700/health"]
retries: 3
timeout: 5s
mailhog:
image: 'mailhog/mailhog:latest'
ports:
- '${FORWARD_MAILHOG_PORT:-1025}:1025'
- '${FORWARD_MAILHOG_DASHBOARD_PORT:-8025}:8025'
networks:
- sail
selenium:
image: 'selenium/standalone-chrome'
volumes:
- '/dev/shm:/dev/shm'
networks:
- sail
networks:
sail:
driver: bridge
volumes:
sail-mysql:
driver: local
sail-redis:
driver: local
sail-meilisearch:
driver: local
docker ps results
paul#MBP-Paul Sites % docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
90274792c508 sail-8.1/app "start-container" 18 hours ago Up 18 hours 0.0.0.0:80->80/tcp, 8000/tcp example-app_laravel.test_1
904074d309de mysql/mysql-server:8.0 "/entrypoint.sh mysq…" 18 hours ago Up 18 hours (healthy) 0.0.0.0:3306->3306/tcp, 33060-33061/tcp example-app_mysql_1
d1d7d685c090 selenium/standalone-chrome "/opt/bin/entry_poin…" 18 hours ago Up 18 hours 4444/tcp, 5900/tcp example-app_selenium_1
c98e1ba83569 mailhog/mailhog:latest "MailHog" 18 hours ago Up 18 hours 0.0.0.0:1025->1025/tcp, 0.0.0.0:8025->8025/tcp example-app_mailhog_1
414d916be277 redis:alpine "docker-entrypoint.s…" 18 hours ago Up 18 hours (healthy) 0.0.0.0:6379->6379/tcp example-app_redis_1
a384df0d281c getmeili/meilisearch:latest "tini -- /bin/sh -c …" 18 hours ago Up 18 hours (healthy) 0.0.0.0:7700->7700/tcp example-app_meilisearch_1

net::ERR_CONNECTION_REFUSED using Laravel 9 with Laravel Sail on PHP 8.1

I am building an app with Laravel, Vue 3 and Inertia.js.
I tried to set up a development server with Laravel Sail.
I have docker running in my machine and all the containers are running, the problem is that whenever I access localhost it throws me these errors even though after I run the script sail npm run hot:
GET http://localhost:3000/browser-sync/browser-sync-client.js net::ERR_CONNECTION_REFUSED
GET http://localhost:8080/css/app.css net::ERR_CONNECTION_REFUSED
GET http://localhost:8080/css/all.min.css net::ERR_CONNECTION_REFUSED
GET http://localhost:8080/js/manifest.js net::ERR_CONNECTION_REFUSED
GET http://localhost:8080/js/vendor.js net::ERR_CONNECTION_REFUSED
GET http://localhost:8080/js/app.js net::ERR_CONNECTION_REFUSED
My docker-compose.yml file contains the following:
version: '3'
services:
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
mysql:
image: 'mysql:8.0'
ports:
- '${FORWARD_DB_PORT:-3306}:3306'
environment:
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
MYSQL_DATABASE: '${DB_DATABASE}'
MYSQL_USER: '${DB_USERNAME}'
MYSQL_PASSWORD: '${DB_PASSWORD}'
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
volumes:
- 'sailmysql:/var/lib/mysql'
networks:
- sail
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-p${DB_PASSWORD}"]
retries: 3
timeout: 5s
redis:
image: 'redis:alpine'
ports:
- '${FORWARD_REDIS_PORT:-6379}:6379'
volumes:
- 'sailredis:/data'
networks:
- sail
healthcheck:
test: ["CMD", "redis-cli", "ping"]
retries: 3
timeout: 5s
meilisearch:
image: 'getmeili/meilisearch:latest'
ports:
- '${FORWARD_MEILISEARCH_PORT:-7700}:7700'
volumes:
- 'sailmeilisearch:/data.ms'
networks:
- sail
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--spider", "http://localhost:7700/health"]
retries: 3
timeout: 5s
mailhog:
image: 'mailhog/mailhog:latest'
ports:
- '${FORWARD_MAILHOG_PORT:-1025}:1025'
- '${FORWARD_MAILHOG_DASHBOARD_PORT:-8025}:8025'
networks:
- sail
selenium:
image: 'selenium/standalone-chrome'
volumes:
- '/dev/shm:/dev/shm'
networks:
- sail
networks:
sail:
driver: bridge
volumes:
sailmysql:
driver: local
sailredis:
driver: local
sailmeilisearch:
driver: local
I am on a Windows 11 machine using WSL2 and Ubuntu-20.04

Getting error "cURL error 7: Failed to connect to localhost port" when calling API from another container

I am dockerizing an app that has several different services and I have used the Docker Compose file to achieve this Single docker-compose.yml file for all the services and one Dockerfile for each service.
Frontend(angular)[http://localhost:4200]
Backend(PHP)[http://localhost:80]
Backend Database(Mysql)
Integration Service(NodeJS)[http://localhost:4433]
Integration Service Database(MongoDB)
Authentication Layer(NodeJS)[http://localhost:4454]
Authentication Layer Database(Mysql)
So far I have successfully containerized all these services but when my "Backend(PHP)" container tries to call API from "Integration Service(NodeJS)" it throws the error which is cURL error 7: Failed to connect to localhost port 4433: Connection refused (see http://curl.haxx.se/libcurl/c/libcurl-errors.html).
services:
angular-service:
container_name: wms_frontend
build: ../frontend/.
ports:
- "4200:80"
php:
build:
context: .
image: wms-backend
networks:
- frontend
- backend
environment:
- MYSQL_HOST=wms-backend-mysql-app
- MYSQL_USER=wmsroot
- MYSQL_PASSWORD=pass
- MYSQL_DB=dbname
volumes:
- ./:/var/www/html/wms/backend
ports:
- "80:80"
container_name: wms-backend-php-app
mysql:
image: mysql:5.7
networks:
- backend
environment:
- MYSQL_ROOT_PASSWORD=rootpassword
- MYSQL_USER=wmsroot
- MYSQL_PASSWORD=pass
- MYSQL_DATABASE=
volumes:
- ./dump:/docker-entrypoint-initdb.d
container_name: wms-backend-mysql-app
phpmyadmin:
image: phpmyadmin/phpmyadmin:4.7
depends_on:
- mysql
networks:
- backend
ports:
- "40002:80"
environment:
- PMA_HOST=wms-backend-mysql-app
- PMA_PORT= 3306
volumes:
- /sessions
container_name: wms-backend-phpmyadmin-app
app:
container_name: wms_auth
restart: always
build: ../../wms_auth/.
networks:
- backend
volumes:
- ../../auth/./:/usr/src/app
- /usr/src/app/node_modules
ports:
- "4454:4454"
links:
- db
depends_on:
db:
condition: service_healthy
db:
image: mariadb
restart: always
ports:
- "3308:3306"
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD= YES
- MYSQL_DATABASE=auth
- MYSQL_USER= root
- MYSQL_PASSWORD=
volumes:
- ../../auth/dump/:/docker-entrypoint-initdb.d
networks:
- backend
healthcheck:
test: ["CMD", "mysql", "-h", "db","-u","root", "mysql", "-e", "select 1"]
interval: 1s
retries: 20
wms_integration:
container_name: integration
restart: always
build: ../../wmsIntegeration/.
volumes:
- ../../wmsIntegeration/./:/usr/src/app
- /usr/src/app/node_modules
ports:
- "4433:4433"
networks:
- backend
links:
- db
depends_on:
db:
condition: service_healthy
wms_integration_db:
image: mongo
restart: always
networks:
- backend
ports:
- "27019:27017"
volumes:
- ../../wmsIntegeration/mongodb:/data/db
healthcheck:
test: echo 'db.runCommand("ping").ok' | mongo db:27017/config --quiet
interval: 10s
timeout: 10s
retries: 5
networks:
local:
driver: bridge
networks:
frontend:
backend:
Bridge all the networks as follows :
networks:
local:
driver: bridge
frontend:
driver: bridge
backend:
driver: bridge

How to run queue work on Laravel with docker?

I create an docker setup on my Laravel project using sail.
În my project I use jobs and I want when I run docker-compose up to start command php artisan queue:work. In my docker-compose.yml I defined an service php-queue like this:
# For more information: https://laravel.com/docs/sail
version: '3'
services:
laravel.test:
build:
context: ./docker/8.0
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP}'
image: sail-8.0/app
ports:
- '${APP_PORT:-80}:80'
environment:
WWWUSER: '${WWWUSER}'
LARAVEL_SAIL: 1
volumes:
- '.:/var/www/html'
networks:
- sail
depends_on:
- mysql
- redis
php-queue:
restart: always
image: sail-8.0/app:latest
command: 'php artisan queue:work'
volumes:
- '.:/var/www/html'
mysql:
image: 'mysql:5.7'
ports:
- '${FORWARD_DB_PORT:-3306}:3306'
environment:
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
MYSQL_DATABASE: '${DB_DATABASE}'
MYSQL_USER: '${DB_USERNAME}'
MYSQL_PASSWORD: '${DB_PASSWORD}'
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
volumes:
- 'sailmysql:/var/lib/mysql'
networks:
- sail
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-p${DB_PASSWORD}"]
retries: 3
timeout: 5s
redis:
image: 'redis:alpine'
ports:
- '${FORWARD_REDIS_PORT:-6379}:6379'
volumes:
- 'sailredis:/data'
networks:
- sail
healthcheck:
test: [ "CMD", "redis-cli", "ping" ]
retries: 3
timeout: 5s
networks:
sail:
driver: bridge
volumes:
sailmysql:
driver: local
sailredis:
driver: local
when I run docker-conpose up in docker desktop it shows this error:
error: failed switching to "php": unable to find user php: no matching entries in passwd file
what I missed?
change command: 'php artisan queue:work' to command: ['/bin/sh', '-c', 'php artisan queue:work' thats should work
Also this could help you :)
https://laravel.com/docs/8.x/sail#executing-sail-commands
Running Artisan commands locally...
php artisan queue:work
Running Artisan commands within Laravel Sail...
sail artisan queue:work

Categories