title: Docker mysql container does not allow remote connection
body: <p>I have an error <code>Access denied for user 'bonus_user'@'my-ip' (using password: YES)</code> when trying to connect from my mysql client to dockerized mysql server on remote machine</p>
  <p>My docker-compose file:</p>
  <pre><code>bonus_db:
   container_name: bonus_db
   image: mysql:5.7
   command: --default-authentication-plugin=mysql_native_password
   restart: unless-stopped
   ports:
     - &quot;3306:3306&quot;
   environment:
     MYSQL_USER: bonus_user
     MYSQL_PASSWORD: bonus_pass
     MYSQL_DATABASE: bonus_db
     MYSQL_ROOT_PASSWORD: root_pass
  volumes:
    - /var/lib/volumes/bonusdata:/var/lib/mysql
  </code></pre>
  <p>Here's also log of container starting:</p>
  <pre><code>bonus_db    | 2020-11-14 15:06:05+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.31-1debian10 started.
  bonus_db    | 2020-11-14 15:06:05+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
  bonus_db    | 2020-11-14 15:06:05+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.31-1debian10 started.
  bonus_db    | 2020-11-14T15:06:06.470897Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  bonus_db    | 2020-11-14T15:06:06.480712Z 0 [Note] mysqld (mysqld 5.7.31) starting as process 1 ...
  bonus_db    | 2020-11-14T15:06:06.502124Z 0 [Note] InnoDB: PUNCH HOLE support available
  bonus_db    | 2020-11-14T15:06:06.504807Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
  bonus_db    | 2020-11-14T15:06:06.504851Z 0 [Note] InnoDB: Uses event mutexes
  bonus_db    | 2020-11-14T15:06:06.504878Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
  bonus_db    | 2020-11-14T15:06:06.504894Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
  bonus_db    | 2020-11-14T15:06:06.504906Z 0 [Note] InnoDB: Using Linux native AIO
  bonus_db    | 2020-11-14T15:06:06.505684Z 0 [Note] InnoDB: Number of pools: 1
  bonus_db    | 2020-11-14T15:06:06.506021Z 0 [Note] InnoDB: Using CPU crc32 instructions
  bonus_db    | 2020-11-14T15:06:06.522229Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
  bonus_db    | 2020-11-14T15:06:06.548073Z 0 [Note] InnoDB: Completed initialization of buffer pool
  bonus_db    | 2020-11-14T15:06:06.554315Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
  bonus_db    | 2020-11-14T15:06:06.568903Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
  bonus_db    | 2020-11-14T15:06:06.603166Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
  bonus_db    | 2020-11-14T15:06:06.605892Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
  bonus_db    | 2020-11-14T15:06:06.654737Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
  bonus_db    | 2020-11-14T15:06:06.656736Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
  bonus_db    | 2020-11-14T15:06:06.656771Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
  bonus_db    | 2020-11-14T15:06:06.657961Z 0 [Note] InnoDB: Waiting for purge to start
  bonus_db    | 2020-11-14T15:06:06.708340Z 0 [Note] InnoDB: 5.7.31 started; log sequence number 13750567
  bonus_db    | 2020-11-14T15:06:06.709023Z 0 [Note] Plugin 'FEDERATED' is disabled.
  bonus_db    | 2020-11-14T15:06:06.711205Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
  bonus_db    | 2020-11-14T15:06:06.715836Z 0 [Note] InnoDB: Buffer pool(s) load completed at 201114 15:06:06
  bonus_db    | 2020-11-14T15:06:06.721862Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
  bonus_db    | 2020-11-14T15:06:06.721918Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
  bonus_db    | 2020-11-14T15:06:06.723943Z 0 [Warning] CA certificate ca.pem is self signed.
  bonus_db    | 2020-11-14T15:06:06.724051Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
  bonus_db    | 2020-11-14T15:06:06.725417Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
  bonus_db    | 2020-11-14T15:06:06.725502Z 0 [Note] IPv6 is available.
  bonus_db    | 2020-11-14T15:06:06.725525Z 0 [Note]   - '::' resolves to '::';
  bonus_db    | 2020-11-14T15:06:06.725562Z 0 [Note] Server socket created on IP: '::'.
  bonus_db    | 2020-11-14T15:06:06.740164Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
  bonus_db    | 2020-11-14T15:06:06.765251Z 0 [Note] Event Scheduler: Loaded 0 events
  bonus_db    | 2020-11-14T15:06:06.765978Z 0 [Note] mysqld: ready for connections.
  bonus_db    | Version: '5.7.31'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL)
  </code></pre>
  <p>I tried to log in into container on remote machine like this:</p>
  <pre><code>docker exec -i bonus_db mysql -ubonus_user -pbonus_pass
  </code></pre>
  <p>And it seems working, because if I pass wrong password here, it will give the same error <code>Access denied</code>. I've also tried to import data from sql file</p>
  <pre><code>docker exec -i bonus_db mysql -ubonus_user -pbonus_pass bonus_db &lt; dump.sql
  </code></pre>
  <p>and it also seems working, it's processing a couple of seconds and then exits to the terminal. But I cant access database from my local machine and from other containers too.</p>