Categories
docker-compose mysql

Create database on docker-compose startup

I would like to create a MySQL database using environment variables in docker-compose.yml file, but it is not working. I have the following code:

# The Database
database:
image: mysql:5.7
volumes:
- dbdata:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: homestead
MYSQL_USER: root
MYSQL_PASSWORD: secret
ports:
- "33061:3306"

Could someone explain the function of this vars?