laravel / valet

A more enjoyable local development experience for Mac.
https://laravel.com/docs/valet
MIT License
2.5k stars 690 forks source link

Valet breaks Docker on M1 #1031

Closed tholu closed 3 years ago

tholu commented 3 years ago

Clear description of your problem

The dnsmasq server of valet breaks docker on MacOS Big Sur 11.2 (M1 Apple Silicon)

Expected behavior

Docker should work fine alongside Laravel valet.

Current behavior

Pulling images with docker is not working anymore when dnsmasq runs:

ERROR: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io on 192.168.64.1:53: read udp 192.168.64.2:58044->192.168.64.1:53: read: connection refused

Steps to Reproduce

  1. Install Laravel Valet
  2. Install Docker M1 Tech Preview https://docs.docker.com/docker-for-mac/apple-m1/
  3. Start Laravel Valet + Docker
  4. Try to pull any image, e.g. via docker-compose pull

Output of these steps

ERROR: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io on 192.168.64.1:53: read udp 192.168.64.2:58044->192.168.64.1:53: read: connection refused

Possible solution

dnsmasq config that is not breaking Docker, see also this Reddit comment (sorry, linking to Reddit sucks)

Diagnosis

valet/dnsmasq stopped intentionally to get Docker working again.

sw_vers
ProductName:   macOS
ProductVersion: 11.2
BuildVersion:   20D64
valet --version
Laravel Valet 2.13.19
cat ~/.config/valet/config.json
{
    "tld": "test",
    "paths": [
        "/Users/thomaslutz/.config/valet/Sites",
        "/Users/thomaslutz/Developer/laravel"
    ]
}
cat ~/.composer/composer.json
{
    "require": {
        "laravel/valet": "^2.13"
    }
}
composer global diagnose
Changed current directory to /Users/thomaslutz/.composer
Checking composer.json: WARNING
No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys: 
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: OK
Composer version: 2.0.9
PHP version: 8.0.2
PHP binary path: /opt/homebrew/Cellar/php/8.0.2/bin/php
OpenSSL version: OpenSSL 1.1.1i  8 Dec 2020
cURL version: 7.75.0 libz 1.2.11 ssl (SecureTransport) OpenSSL/1.1.1i
zip: extension present, unzip present
composer global outdated
Changed current directory to /Users/thomaslutz/.composer
ls -al /etc/sudoers.d/
total 0
drwxr-xr-x   2 root  wheel    64 Jan  1  2020 .
drwxr-xr-x  88 root  wheel  2816 Feb  5 01:04 ..
brew config
HOMEBREW_VERSION: 2.7.7
ORIGIN: https://github.com/Homebrew/brew
HEAD: cd191a7f6c4c8e053336d0ea34a9886b12d06470
Last commit: 7 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 8ffcfb23933067176fe9d330267fddfe2ae4e897
Core tap last commit: 38 minutes ago
Core tap branch: master
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: nano
HOMEBREW_MAKE_JOBS: 8
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit arm_firestorm_icestorm
Clang: 12.0 build 1200
Git: 2.24.3 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 7.64.1 => /usr/bin/curl
Java: 15.0.2, 13.0.6
macOS: 11.2-arm64
CLT: 12.4.0.0.1.1610135815
Xcode: 12.4
Rosetta 2: false
brew services list
Name    Status  User       Plist
consul  stopped            
dnsmasq stopped            
mariadb started thomaslutz /Users/thomaslutz/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
nginx   stopped            
php     unknown root       /Library/LaunchDaemons/homebrew.mxcl.php.plist
redis   stopped            
unbound stopped
brew list --formula --versions | grep -E "(php|nginx|dnsmasq|mariadb|mysql|mailhog|openssl)(@\d\..*)?\s"
dnsmasq 2.84
mariadb 10.5.8
nginx 1.19.6
openssl@1.1 1.1.1i
php 8.0.2 8.0.1_1
brew outdated
youtube-dl
brew tap
hashicorp/tap
homebrew/cask
homebrew/core
homebrew/services
minio/stable
shivammathur/php
tholu/tap
php -v
PHP 8.0.2 (cli) (built: Feb  4 2021 12:48:26) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.2, Copyright (c), by Zend Technologies
which -a php
/opt/homebrew/bin/php
/usr/bin/php
php --ini
Configuration File (php.ini) Path: /opt/homebrew/etc/php/8.0
Loaded Configuration File:         /opt/homebrew/etc/php/8.0/php.ini
Scan for additional .ini files in: /opt/homebrew/etc/php/8.0/conf.d
Additional .ini files parsed:      /opt/homebrew/etc/php/8.0/conf.d/error_log.ini,
/opt/homebrew/etc/php/8.0/conf.d/ext-opcache.ini,
/opt/homebrew/etc/php/8.0/conf.d/php-memory-limits.ini
nginx -v
nginx version: nginx/1.19.6
curl --version
curl 7.64.1 (x86_64-apple-darwin20.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.41.0
Release-Date: 2019-03-27
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS GSS-API HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL UnixSockets
php --ri curl
curl

cURL support => enabled
cURL Information => 7.75.0
Age => 8
Features
AsynchDNS => Yes
CharConv => No
Debug => No
GSS-Negotiate => No
IDN => Yes
IPv6 => Yes
krb4 => No
Largefile => Yes
libz => Yes
NTLM => Yes
NTLMWB => Yes
SPNEGO => Yes
SSL => Yes
SSPI => No
TLS-SRP => Yes
HTTP2 => Yes
GSSAPI => Yes
KERBEROS5 => Yes
UNIX_SOCKETS => Yes
PSL => No
HTTPS_PROXY => Yes
MULTI_SSL => Yes
BROTLI => Yes
Protocols => dict, file, ftp, ftps, gopher, gophers, http, https, imap, imaps, ldap, ldaps, mqtt, pop3, pop3s, rtmp, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp
Host => arm-apple-darwin20.3.0
SSL Version => (SecureTransport) OpenSSL/1.1.1i
ZLib Version => 1.2.11
libSSH Version => libssh2/1.9.0

Directive => Local Value => Master Value
curl.cainfo => no value => no value
~/.composer/vendor/laravel/valet/bin/ngrok version
ngrok version 2.3.35
ls -al ~/.ngrok2
ls: /Users/thomaslutz/.ngrok2: No such file or directory
brew info nginx
nginx: stable 1.19.6 (bottled), HEAD
HTTP(S) server and reverse proxy, and IMAP/POP3 proxy server
https://nginx.org/
/opt/homebrew/Cellar/nginx/1.19.6 (25 files, 2.2MB) *
  Poured from bottle on 2021-02-02 at 02:23:18
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/nginx.rb
License: BSD-2-Clause
==> Dependencies
Required: openssl@1.1, pcre
==> Options
--HEAD
    Install HEAD version
==> Caveats
Docroot is: /opt/homebrew/var/www

The default port has been set in /opt/homebrew/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

nginx will load all files in /opt/homebrew/etc/nginx/servers/.

To have launchd start nginx now and restart at login:
  brew services start nginx
Or, if you don't want/need a background service you can just run:
  nginx
==> Analytics
install: 37,942 (30 days), 127,223 (90 days), 453,912 (365 days)
install-on-request: 37,870 (30 days), 126,446 (90 days), 445,039 (365 days)
build-error: 0 (30 days)
brew info php
php: stable 8.0.2 (bottled), HEAD
General-purpose scripting language
https://www.php.net/
/opt/homebrew/Cellar/php/8.0.1_1 (497 files, 77.8MB)
  Built from source
/opt/homebrew/Cellar/php/8.0.2 (499 files, 77.9MB) *
  Poured from bottle on 2021-02-05 at 00:57:44
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/php.rb
License: PHP-3.01
==> Dependencies
Build: httpd, pkg-config
Required: apr, apr-util, argon2, aspell, autoconf, curl, freetds, gd, gettext, glib, gmp, icu4c, krb5, libffi, libpq, libsodium, libzip, oniguruma, openldap, openssl@1.1, pcre2, sqlite, tidy-html5, unixodbc
==> Options
--HEAD
    Install HEAD version
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
    LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/libphp.so

    
        SetHandler application/x-httpd-php
    

Finally, check DirectoryIndex includes index.php
    DirectoryIndex index.php index.html

The php.ini and php-fpm.ini file can be found in:
    /opt/homebrew/etc/php/8.0/

To have launchd start php now and restart at login:
  brew services start php
Or, if you don't want/need a background service you can just run:
  php-fpm
==> Analytics
install: 54,334 (30 days), 159,785 (90 days), 613,931 (365 days)
install-on-request: 53,258 (30 days), 156,629 (90 days), 591,737 (365 days)
build-error: 0 (30 days)
brew info openssl
openssl@1.1: stable 1.1.1i (bottled) [keg-only]
Cryptography and SSL/TLS Toolkit
https://openssl.org/
/opt/homebrew/Cellar/openssl@1.1/1.1.1i (8,067 files, 18MB)
  Poured from bottle on 2021-02-01 at 14:21:41
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/openssl@1.1.rb
License: OpenSSL
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /opt/homebrew/etc/openssl@1.1/certs

and run
  /opt/homebrew/opt/openssl@1.1/bin/c_rehash

openssl@1.1 is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS provides LibreSSL.

If you need to have openssl@1.1 first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc

For compilers to find openssl@1.1 you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/include"

For pkg-config to find openssl@1.1 you may need to set:
  export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@1.1/lib/pkgconfig"

==> Analytics
install: 721,219 (30 days), 2,258,829 (90 days), 8,173,127 (365 days)
install-on-request: 114,367 (30 days), 358,011 (90 days), 1,181,183 (365 days)
build-error: 0 (30 days)
openssl version -a
LibreSSL 2.8.3
built on: date not available
platform: information not available
options:  bn(64,64) rc4(ptr,int) des(idx,cisc,16,int) blowfish(idx) 
compiler: information not available
OPENSSLDIR: "/private/etc/ssl"
openssl ciphers
ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:GOST2012256-GOST89-GOST89:DHE-RSA-CAMELLIA256-SHA256:DHE-RSA-CAMELLIA256-SHA:GOST2001-GOST89-GOST89:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:CAMELLIA256-SHA256:CAMELLIA256-SHA:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-CAMELLIA128-SHA256:DHE-RSA-CAMELLIA128-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:CAMELLIA128-SHA256:CAMELLIA128-SHA:ECDHE-RSA-RC4-SHA:ECDHE-ECDSA-RC4-SHA:RC4-SHA:RC4-MD5:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:DES-CBC3-SHA
sudo nginx -t
nginx: the configuration file /opt/homebrew/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /opt/homebrew/etc/nginx/nginx.conf test is successful
which -a php-fpm
/opt/homebrew/sbin/php-fpm
/usr/sbin/php-fpm
/opt/homebrew/opt/php/sbin/php-fpm -v
PHP 8.0.2 (fpm-fcgi) (built: Feb  4 2021 12:48:29)
Copyright (c) The PHP Group
Zend Engine v4.0.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.2, Copyright (c), by Zend Technologies
sudo /opt/homebrew/opt/php/sbin/php-fpm -y /opt/homebrew/etc/php/8.0/php-fpm.conf --test
[05-Feb-2021 01:10:02] NOTICE: configuration file /opt/homebrew/etc/php/8.0/php-fpm.conf test is successful
ls -al ~/Library/LaunchAgents | grep homebrew
-rw-r--r--   1 thomaslutz  staff   550 Feb  4 16:12 homebrew.mxcl.mariadb.plist
ls -al /Library/LaunchAgents | grep homebrew

ls -al /Library/LaunchDaemons | grep homebrew
-rw-r--r--   1 root  admin   637 Feb  3 15:35 homebrew.mxcl.php.plist
ls -aln /etc/resolv.conf
lrwxr-xr-x  1 0  0  22 Jan  1  2020 /etc/resolv.conf -> ../var/run/resolv.conf
cat /etc/resolv.conf
#
# macOS Notice
#
# This file is not consulted for DNS hostname resolution, address
# resolution, or the DNS query routing mechanism used by most
# processes on this system.
#
# To view the DNS configuration used by this system, use:
#   scutil --dns
#
# SEE ALSO
#   dns-sd(1), scutil(8)
#
# This file is automatically generated.
#
search local
nameserver 2a02:2488:3211:bef0::1
nameserver 192.168.1.1
mattstauffer commented 3 years ago

https://github.com/tighten/takeout/issues/209

Yah, thanks for opening it here. You've diagnosed it correctly; haven't found a permanent solution, but the temporary solution is indeed to valet stop, restart Docker, and then you can valet start again and they should work together.

mattstauffer commented 3 years ago

https://github.com/docker/for-mac/issues/5186

Also related.

tholu commented 3 years ago

@mattstauffer Thanks for the references and the temporary solution!

yhbyun commented 3 years ago

Before executing docker command, you should stop dnsmasq service. sudo brew services stop dnsmasq

RS-Roshi commented 3 years ago

Tried both (uninstalling valet & stopping dnsmasq) but still facing same issue.

jason-klein commented 3 years ago

Docker Desktop preview 3.1.0 (60984) was released on 2021-02-11 https://docs.docker.com/docker-for-mac/apple-m1/

I've been affected by this issue, so I upgraded to the new version of Docker Desktop preview and attempted various combinations of building Docker images and restarting Valet. So far, so good! I haven't encountered the Docker DNS "read: connection refused" error (yet). Unfortunately, I don't know the exact sequence of events that triggered the issue for me.

@tholu Can you upgrade to the latest Docker Desktop for M1 preview and report back if you're still seeing this issue?

tholu commented 3 years ago

@jason-klein Thanks, I just tried it and had no issues anymore. @RS-Roshi Does it fix the issue for you as well?

RS-Roshi commented 3 years ago

@jason-klein Thanks, I just tried it and had no issues anymore. @RS-Roshi Does it fix the issue for you as well?

@tholu yes brother I have solved this issue by restarting after uninstalling the laravel/valet going to try new docker version with valet running hope to get it working as they claim

mattstauffer commented 3 years ago

Closing. Anyone who hits this issue please open a new issue referencing this.