title: Cannot connect to MySQL server hosted in docker from external machine
body: <p>I'm setting up a MySQL server inside a Docker container</p>
  <pre><code>sudo docker run --name test-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password -e MYSQL_USER=desktop -e MYSQL_PASSWORD=password -e MYSQL_ROOT_HOST=% -d mysql
  </code></pre>
  <p>For some reason I can't figure out, an external machine cannot connect to it, no matter what I try.</p>
  <p>Here is the content of <code>my.cnf</code></p>
  <pre><code>root@f9042fc2a105:/# cat /etc/mysql/my.cnf
  # Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
  
  [mysqld]
  pid-file        = /var/run/mysqld/mysqld.pid
  socket          = /var/run/mysqld/mysqld.sock
  datadir         = /var/lib/mysql
  secure-file-priv= NULL
  
  # Custom config should go here
  !includedir /etc/mysql/conf.d/
  </code></pre>
  <p>Here is <code>docker.cnf</code></p>
  <pre><code>root@f9042fc2a105:/# cat /etc/mysql/conf.d/docker.cnf
  [mysqld]
  skip-host-cache
  skip-name-resolve
  </code></pre>
  <p>Here is <code>mysql.cnf</code></p>
  <pre><code># Copyright (c) 2015, 2021, Oracle and/or its affiliates.
  [mysql]
  </code></pre>
  <p>Here is the content of the User table</p>
  <pre><code>mysql&gt; select user, host from mysql.user;
  +------------------+-----------+
  | user             | host      |
  +------------------+-----------+
  | desktop          | %         |
  | root             | %         |
  | mysql.infoschema | localhost |
  | mysql.session    | localhost |
  | mysql.sys        | localhost |
  | root             | localhost |
  +------------------+-----------+
  6 rows in set (0.00 sec)
  </code></pre>
  <p>Here is the error I get when connecting from an external machine using <a href="https://dev.mysql.com/doc/mysql-shell/8.0/en/" rel="nofollow noreferrer">MySQL shell</a>:</p>
  <pre><code> MySQL  JS &gt; \connect --mysql root@192.186.1.85
  Creating a Classic session to 'root@192.186.1.85'
  Please provide the password for 'root@192.186.1.85': ********
  MySQL Error 2013 (HY000): Lost connection to MySQL server at 'waiting for initial communication packet', system error: 10060
  </code></pre>
  <p>The docker host machine has no firewall.</p>