version: "3" # Specifies the version of the Docker Compose file format # Definition of the services to be run services: # Define a service named 'mysql'. mysql: # Use the version 8 of the official MySQL Docker image. image: mysql:8 # Set a custom name for the running container. container_name: mysql # Set environment variables for the MySQL service. environment: # The password for the MySQL root user. MYSQL_ROOT_PASSWORD: password # The name of the default database to be created. MYSQL_DATABASE: dockge # The username for a new user to be created. MYSQL_USER: M_Viper # The password for the new user. MYSQL_PASSWORD: password # Map port 3306 inside the container to port 3306 on the host. ports: - "3306:3306" # Map a volume from the host to the container, for data persistence. # This ensures that the data inside the MySQL container is saved on the host. volumes: - mysql_data:/var/lib/mysql # Define a volume for data persistence. volumes: # Define a named volume for MySQL data mysql_data: # Use the local volume driver driver: local