docker-compose – changing docker hub values not working?

it’s seems so simple, but I honestly can’t find the mistake, I’m sure it’s something really simple.

I have my compose file here:

version: '3.3'

services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "80:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
       WORDPRESS_DB_NAME: wordpress
volumes:
    db_data: {}

It’s just straight from the docker hub.
But if I try to fill in my own data, for example instead of database name “wordpress” we call it “awordpress”. Then the whole thing just stops working, but why?

version: '3.3'

services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: awordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "80:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
       WORDPRESS_DB_NAME: awordpress
volumes:
    db_data: {}

Compose output:

wordpress_1  | Complete! WordPress has been successfully copied to /var/www/html
wordpress_1  |
wordpress_1  | MySQL "CREATE DATABASE" Error: Access denied for user 'wordpress'@'%' to database 'awordpress'
wordpress_1  |
wordpress_1  | WARNING: unable to establish a database connection to 'db:3306'
wordpress_1  |   continuing anyways (which might have unexpected results)

And the weird thing is, it creates a database “wordpress” instead of my inserted “awordpress” via enviornment variables. Why does it “ignore” my variable and creates this value instead?

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| wordpress          |
+--------------------+
5 rows in set (0.00 sec)

Goal is to auto-configure a wordpress with my own data. I’m sure it’s something extremly simple I oversee …
Sorry if it’s a dumb question. I’m very new to docker.
Thanks in advance!

Source: StackOverflow