Why do I lose data if docker restarts?

I am new to docker and would need some advice. I am about to set up my own personal git repository with Gitea. The docker compose file can be seen below. When I first run the file everything is fine. The problem occurs when I restart my computer or Docker then the page loads but it is empty no repos, nothing. Also it is not possible to log in with the credential that were set after first installation. It looks like the connection to the database is lost after restarting.

docker compose file:

version: "2"

networks:
  gitea:
    external: false

volumes:
  gitea:
    driver: local

services:
  server:
    image: gitea/gitea:latest
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - DB_TYPE=mysql
      - DB_HOST=db:3306
      - DB_NAME=gitea
      - DB_USER=gitea
      - DB_PASSWD=gitea
    restart: always
    networks:
      - gitea
    volumes:
      #- ./gitea:/data
       - gitea:/data
    ports:
       - "3000:3000"
       - "222:22"
    depends_on:
      - db

  db:
    image: mysql:5.7
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=gitea
      - MYSQL_USER=gitea
      - MYSQL_PASSWORD=gitea
      - MYSQL_DATABASE=gitea
    networks:
      - gitea
    volumes:
      - ./mysql:/var/lib/mysql

Source: StackOverflow