Gitea docker advice

Hello, I am quite new to Gitea and Docker and I would need an advice.

I installed Gitea on Docker on my local PC and everything was working fine I accessed it trough local ip and port 3000.
After four days Gitea was not reachable from browser - the error was ERR_CONNECTION_REFUSED.

I looked at the containers in docker and they were up and running and also the logs of docker compose were same as always. The Resource monitor in Windows did not list the port 3000 to be in use.

After that I restarted Docker and did docker-compose down followed by docker-compose up -d . Now I can reach Gitea through browser again and also the Resource monitor lists port 3000 to be in use. But now Gitea has lost all its previous content and I cannot log in with my user account, but it is not like clean install since it does not ask me to enter the Settings for Gitea as it did when it was first installed.

So, I would be glad if someone could give me some advice on this topic.
Why was it impossible to reach Gitea after days of installing through browser ?
Does restarting docker and doing docker compose down / up erase all the content ?
What should I avoid in the future tho not loose content on Gitea (in terms of performing actions regarding docker) ?

It sounds like you may not be using docker volumes to persist data. This is something you should be doing for any software you host in docker, not just gitea, because otherwise if a container is deleted or recreated (docker-compose up -d can do this) your data will be deleted.

This is my docker-compose.yml, Which is mostly from Gitea’s website, am I doing anything wrong?

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