{"id":29207735,"url":"https://github.com/jpisnice/mssql-docker-persistent","last_synced_at":"2026-04-25T08:35:12.916Z","repository":{"id":302393984,"uuid":"1012292530","full_name":"Jpisnice/mssql-docker-persistent","owner":"Jpisnice","description":"Simple setup for Microsoft SQL server for local development using Docker","archived":false,"fork":false,"pushed_at":"2025-07-02T06:18:26.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-02T07:21:48.460Z","etag":null,"topics":["development","docker","microsoft-sql-server","sql"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Jpisnice.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-02T05:47:51.000Z","updated_at":"2025-07-02T06:20:58.000Z","dependencies_parsed_at":"2025-07-02T07:21:53.400Z","dependency_job_id":"dce98710-901f-49af-a0b9-f538d910a3b4","html_url":"https://github.com/Jpisnice/mssql-docker-persistent","commit_stats":null,"previous_names":["jpisnice/mssql-docker-persistent"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Jpisnice/mssql-docker-persistent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jpisnice%2Fmssql-docker-persistent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jpisnice%2Fmssql-docker-persistent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jpisnice%2Fmssql-docker-persistent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jpisnice%2Fmssql-docker-persistent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jpisnice","download_url":"https://codeload.github.com/Jpisnice/mssql-docker-persistent/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jpisnice%2Fmssql-docker-persistent/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263204775,"owners_count":23430292,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["development","docker","microsoft-sql-server","sql"],"created_at":"2025-07-02T19:38:12.413Z","updated_at":"2026-04-25T08:35:12.903Z","avatar_url":"https://github.com/Jpisnice.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MS SQL Server Docker Container\n\nThis repository contains a Docker setup for Microsoft SQL Server with data persistence.\n\n## Features\n\n- MS SQL Server 2022 Express Edition\n- Data persistence through Docker volumes\n- Easy configuration through environment variables\n- Docker Compose for simplified deployment\n- Includes `sqlcmd` for command-line interaction\n- Helper script (`connect.sh`) for easy connection\n- Example initialization script (`init.sql`)\n\n## Quick Start\n\n### Using Docker Compose (Recommended)\n\n1. **Clone and navigate to the directory**\n   ```bash\n   cd /path/to/your/project\n   ```\n\n2. **Create environment file**\n   ```bash\n   cp .env.example .env\n   ```\n   \n3. **Edit the `.env` file and set a strong password**\n   ```bash\n   nano .env\n   ```\n   \n4. **Build and start the SQL Server container**\n   ```bash\n   docker compose up --build -d\n   ```\n\n## Configuration\n\n### Environment Variables\n\n- `ACCEPT_EULA`: Must be set to `Y` to accept the End-User License Agreement\n- `MSSQL_SA_PASSWORD`: Password for the SA account (must meet complexity requirements)\n- `MSSQL_PID`: SQL Server edition (Express, Developer, Standard, Enterprise, or ProductID)\n- `MSSQL_TCP_PORT`: TCP port for SQL Server (default: 1433)\n\n### Password Requirements\n\nThe SA password must meet the following requirements:\n- At least 8 characters long\n- Contains characters from at least 3 of these categories:\n  - Uppercase letters (A-Z)\n  - Lowercase letters (a-z)\n  - Numbers (0-9)\n  - Special characters (!@#$%^\u0026*()_+-=[]{}|;'\\\",./\u003c\u003e?)\n\n## Data Persistence\n\nThe following directories are mounted as volumes for data persistence:\n- `/var/opt/mssql/data` - Database files\n- `/var/opt/mssql/log` - Transaction log files\n- `/var/opt/mssql/backup` - Backup files\n\n## Connecting to SQL Server\n\n### Using the Connection Script (Recommended)\n\nA helper script is provided for convenience:\n\n- **Linux/macOS:**\n  1. Make the script executable:\n     ```bash\n     chmod +x connect.sh\n     ```\n  2. Run the script:\n     ```bash\n     ./connect.sh\n     ```\n     This will open an interactive `sqlcmd` session.\n\n- **Windows:**\n  1. Double-click `connect.bat` or run it from Command Prompt:\n     ```bat\n     connect.bat\n     ```\n     This will open an interactive `sqlcmd` session in the container.\n\n### Using SQL Server Management Studio (SSMS)\n\nTo connect to the SQL Server instance running in Docker using SSMS:\n\n1. **Start the container** (if not already running):\n   ```bash\n   docker compose up -d\n   ```\n2. **Open SQL Server Management Studio (SSMS)** on your Windows machine.\n3. **Connect to the server:**\n   - **Server type:** Database Engine\n   - **Server name:** `localhost,1433` (or use your Docker host's IP, e.g., `192.168.x.x,1433` if connecting from another machine)\n   - **Authentication:** SQL Server Authentication\n   - **Login:** `sa`\n   - **Password:** The value you set for `MSSQL_SA_PASSWORD` in your `.env` file (default: `YourStrong@Passw0rd`)\n4. **Click Connect.**\n\nIf you have issues connecting from another machine, ensure port 1433 is open and accessible on your Docker host.\n\n### Using sqlcmd Manually\n\nYou can also connect manually using `docker exec`:\n```bash\n# Connect from your host machine\ndocker exec -it mssql-server sqlcmd -S localhost -U sa -P 'YourStrong@Passw0rd'\n```\n\n## Database Initialization\n\nAn example script `init.sql` is provided to create a sample database and table.\n\nTo run the script:\n```bash\ndocker exec -i mssql-server sqlcmd -S localhost -U sa -P 'YourStrong@Passw0rd' \u003c init.sql\n```\nThis will:\n1. Create a database named `TestDB`.\n2. Create a table named `Employees`.\n3. Insert a sample record into the `Employees` table.\n\n## Management Commands\n\n### View container logs\n```bash\ndocker compose logs -f mssql\n```\n\n### Stop the container\n```bash\ndocker compose down\n```\n\n### Remove everything (including volumes)\n```bash\ndocker compose down -v\n```\n\n### Backup database\n```bash\n# Example backup command\ndocker exec mssql-server sqlcmd -S localhost -U sa -P 'YourStrong@Passw0rd' -Q \"BACKUP DATABASE [TestDB] TO DISK = '/var/opt/mssql/backup/TestDB.bak'\"\n```\n\n## Security Notes\n\n1. **Change the default password** - Never use the example password in production\n2. **Use environment files** - Keep sensitive data in `.env` files that are not committed to version control\n3. **Network security** - Consider using Docker networks and firewall rules\n4. **Regular updates** - Keep the SQL Server image updated\n\n## Troubleshooting\n\n### Container won't start or is in a restart loop\n\n- **Permission Errors (`Access is denied.`):** The container might not have permission to write to the mounted volumes. Ensure that `user: \"0:0\"` is set in the `docker-compose.yml` file to run the container as root.\n- **Build Errors:** If the Docker build fails, it could be due to issues with package installation. Ensure that `gnupg` is installed and that the correct Ubuntu version is specified in the `Dockerfile` for the Microsoft package repository.\n- **Password Complexity:** Ensure the `MSSQL_SA_PASSWORD` meets the complexity requirements.\n- **Port Conflicts:** Make sure port 1433 is not already in use on your host machine.\n- **Check Logs:** Always check the container logs for specific error messages: `docker-compose logs mssql`\n\n### Can't connect to SQL Server\n\n- **Container Status:** Verify the container is running with `docker ps`.\n- **Port Accessibility:** Check if the port is accessible from your host: `telnet localhost 1433`.\n- **Credentials:** Double-check the server name, username, and password in your connection string.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpisnice%2Fmssql-docker-persistent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpisnice%2Fmssql-docker-persistent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpisnice%2Fmssql-docker-persistent/lists"}