{"id":28287340,"url":"https://github.com/technocake/dotnet-sql-on-unix","last_synced_at":"2026-01-27T16:06:54.887Z","repository":{"id":145419744,"uuid":"411609675","full_name":"technocake/dotnet-sql-on-unix","owner":"technocake","description":"Using docker compose for hosting a local mssql server (for local development)","archived":false,"fork":false,"pushed_at":"2021-09-29T10:36:57.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-18T04:41:45.638Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/technocake.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":"2021-09-29T09:26:48.000Z","updated_at":"2021-09-29T10:37:00.000Z","dependencies_parsed_at":"2023-06-26T05:16:16.063Z","dependency_job_id":null,"html_url":"https://github.com/technocake/dotnet-sql-on-unix","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/technocake/dotnet-sql-on-unix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technocake%2Fdotnet-sql-on-unix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technocake%2Fdotnet-sql-on-unix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technocake%2Fdotnet-sql-on-unix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technocake%2Fdotnet-sql-on-unix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/technocake","download_url":"https://codeload.github.com/technocake/dotnet-sql-on-unix/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technocake%2Fdotnet-sql-on-unix/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28816531,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T12:25:15.069Z","status":"ssl_error","status_checked_at":"2026-01-27T12:25:05.297Z","response_time":168,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2025-05-21T22:11:23.691Z","updated_at":"2026-01-27T16:06:54.882Z","avatar_url":"https://github.com/technocake.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Using docker compose for database server\n\nDocker compose is a good tool to make running a mssql server on osx/linux even easier.\n\nThe official mssql-server docker image is cumbersome to set up manually each time it is needed. Working with dotnet in a unix environment (linux, OS X etc) often requires you to have a local database server for development.\n\nMany steps done with docker commands to run a container can be configured in \n\ndocker-compose.yml file instead.  Docker is the engine behind everything. Docker-compose is more like a conductor for the orchestra - making sure each player plays it part in harmony with the rest.\n\n\n\n| Configuration parameter | Value          |\n| ----------------------- | -------------- |\n| server                  | localhost      |\n| port                    | 1433 (default) |\n| User                    | sa             |\n| Password                | S3cr3tPassword |\n| Database name           | DATABASE       |\n\n\n\n## Start the database server\n\n| What to do                           | How to do it                    |\n| ------------------------------------ | ------------------------------- |\n| Start the database server            | `docker compose up`             |\n| Stop the database server             | `docker compose down`           |\n| Remove all data from database server | `docker compose down --volumes` |\n\n\n\n## Import data to database\n\n- Step 1:  Find the container id with [`docker ps`](https://docs.docker.com/engine/reference/commandline/ps/) \n- Step 2: Copy the sql-file to the container ([`docker cp`](https://docs.docker.com/engine/reference/commandline/cp/))\n- Step 3: Execute the file with `sqlcmd`,  from inside the container ([`docker exec`](https://docs.docker.com/engine/reference/commandline/exec/))\n\n\n\n### Step 1 Find the container id with [`docker ps`](https://docs.docker.com/engine/reference/commandline/ps/) \n\nAfter your database container is running, type `docker ps` in your terminal, it will display a list of all running containers and their ids:\n\n\u003e `\u003e docker ps`\n\u003e\n\u003e ```bash\n\u003e CONTAINER ID  IMAGE                 COMMAND         CREATED    STATUS     PORTS                    NAMES\n\u003e \n\u003e 78d5fffabbb9  microsoft/mssql-server-linux:latest  \"/opt/mssql/bin/sqls…\"  17 hours ago  Up 7 minutes  0.0.0.0:1433-\u003e1433/tcp, :::1433-\u003e1433/tcp  student_db_1\n\u003e ```\n\nThe containerid is in the first column, and in this case is: `78d5fffabbb9`\n\n\n\n### Step 2: Copy the sql-file to the container ([`docker cp`](https://docs.docker.com/engine/reference/commandline/cp/))\n\n\n\n`docker cp database.sql 78d5fffabbb9:/`\n\n\n\n### Step 3: Run the sql statements \n\nNow you will do two things:\n\n1. Open a shell inside the container with `docker exec`\n2. Run a command from inside the container that imports the data to the database.\n\n\n\n#### 1. Open a shell  inside the container.\n\n```bash\ndocker exec -ti 78d5fffabbb9 bash\n```\n\n#### 2. Import data to database\n\nRun this command, expected result is displayed further down.\n\n```bash\n/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P S3cr3tPassword -i database.sql \t\n```\n\nExpected result:\n\n```bash\nroot@78d5fffabbb9:/# /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P S3cr3tPassword -i database.sql \nChanged database context to 'master'.\nChanged database context to 'DATABASE'.\n\n(1 rows affected)\n\n(1 rows affected)\n\n(1 rows affected)\n\n(1 rows affected)\n\n(1 rows affected)\n\n(1 rows affected)\n\n(1 rows affected)\n\n(1 rows affected)\n\n(1 rows affected)\n\n(1 rows affected)\n\n(1 rows affected)\n\n(1 rows affected)\n\n(1 rows affected)\n\n```\n\n\n\n\n\n## Connect to database from application\n\n**Connectionstring**\n\n```sql\n\"Server=localhost;Database=DATABASE;User Id=sa;Password=S3cr3tPassword\"\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechnocake%2Fdotnet-sql-on-unix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechnocake%2Fdotnet-sql-on-unix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechnocake%2Fdotnet-sql-on-unix/lists"}