Follow these steps to upgrade a Docker installation of MySQL 5.7 to 8.0:

# Stop MySQL 5.7
[root@ec-g database]# docker stop ec.mysql.57 
# Start MySQL 8
[root@ec-g database]# docker run --name ec.mysql \
>   --mount type=bind,src=/ec_data/mysql-db/database,dst=/var/lib/mysql \
>   --mount type=bind,src=/ec_data/mysql-db/database/my.cnf,dst=/etc/my.cnf \
>   -p 3306:3306 -d mysql:8
# Execute Upgrade
[root@ec-g database]# docker exec -it ec.mysql mysql_upgrade -uroot -p
Enter password: 
Checking if update is needed.
Checking server version.
Running queries to upgrade MySQL server.
Upgrading system table data.
Checking system database.
mysql.columns_priv                                 OK
mysql.component                                    OK
mysql.db                                           OK
mysql.default_roles                                OK
mysql.engine_cost                                  OK
mysql.func                                         OK
mysql.general_log                                  OK
mysql.global_grants                                OK
mysql.gtid_executed                                OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.innodb_index_stats                           OK
mysql.innodb_table_stats                           OK
mysql.ndb_binlog_index                             OK
mysql.password_history                             OK
mysql.plugin                                       OK
mysql.procs_priv                                   OK
mysql.proxies_priv                                 OK
mysql.role_edges                                   OK
mysql.server_cost                                  OK
mysql.servers                                      OK
mysql.slave_master_info                            OK
mysql.slave_relay_log_info                         OK
mysql.slave_worker_info                            OK
mysql.slow_log                                     OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK
Found outdated sys schema version 1.5.1.
Upgrading the sys schema.
Checking databases.
nextcloud_db.oc_accounts                           OK
sys.sys_config                                     OK
Upgrade process completed successfully.
Checking if update is needed.