<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Shane Burnham</title>
    <description>The latest articles on Forem by Shane Burnham (@srburnham).</description>
    <link>https://forem.com/srburnham</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F90742%2F285e2f89-b56f-4695-8c52-6d7ba76b7418.jpg</url>
      <title>Forem: Shane Burnham</title>
      <link>https://forem.com/srburnham</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/srburnham"/>
    <language>en</language>
    <item>
      <title>Forget Azure SQL Edge on a M1 Mac—Run full-blown SQL Server Linux instead (a how-to)</title>
      <dc:creator>Shane Burnham</dc:creator>
      <pubDate>Thu, 12 Jan 2023 11:02:11 +0000</pubDate>
      <link>https://forem.com/srburnham/forget-azure-sql-edge-on-a-m1-mac-run-full-blown-sql-server-linux-instead-a-how-to-6d2</link>
      <guid>https://forem.com/srburnham/forget-azure-sql-edge-on-a-m1-mac-run-full-blown-sql-server-linux-instead-a-how-to-6d2</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Update: &lt;a href="https://www.reddit.com/r/SQLServer/comments/10aanku/comment/j43nkhc/?utm_source=share&amp;amp;utm_medium=web2x&amp;amp;context=3" rel="noopener noreferrer"&gt;as pointed out to me on Reddit&lt;/a&gt;, it turns out this just got even easier for those with Docker Desktop installed. The latest release (4.16.0) includes an option to use Rosetta as the emulator similar to what Lima is doing below. Once enabled SQL Server should just work if you set the platform flag to &lt;code&gt;linux/amd64&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;After countless hours entering different terms into various search engines, only to have them all return the same "Run SQL Server on an M1 Mac" results that actually run Azure SQL Edge instead, I have uncovered a simple enough way to run a full version of SQL Server Linux on an M1 Mac.&lt;/p&gt;

&lt;p&gt;For some, running Azure SQL Edge for local development is enough and if it is, go for it (it is likely still the top Google result if you want to go looking)! &lt;/p&gt;

&lt;p&gt;If however you require some of the features missing from the cutdown edge version, or a tool you use for schema versioning requires it (e.g. &lt;a href="https://flywaydb.org" rel="noopener noreferrer"&gt;Flyway&lt;/a&gt;) then hopefully this simple how-to will get you going.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lima to the rescue
&lt;/h2&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.dev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/lima-vm" rel="noopener noreferrer"&gt;
        lima-vm
      &lt;/a&gt; / &lt;a href="https://github.com/lima-vm/lima" rel="noopener noreferrer"&gt;
        lima
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Linux virtual machines, with a focus on running containers
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;p&gt;&lt;a href="https://lima-vm.io/" rel="nofollow noopener noreferrer"&gt;[🌎&lt;strong&gt;Web site&lt;/strong&gt;]&lt;/a&gt;
&lt;a href="https://lima-vm.io/docs/" rel="nofollow noopener noreferrer"&gt;[📖&lt;strong&gt;Documentation&lt;/strong&gt;]&lt;/a&gt;
&lt;a href="https://slack.cncf.io" rel="nofollow noopener noreferrer"&gt;[👤&lt;strong&gt;Slack (&lt;code&gt;#lima&lt;/code&gt;)&lt;/strong&gt;]&lt;/a&gt;&lt;/p&gt;

  
  &lt;img alt="Shows a stylized 'Lima' text in bold, modern font" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Flima-vm%2Flimawebsite%2Fstatic%2Fimages%2Flogo.svg" width="400"&gt;

&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Lima: Linux Machines&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href="https://www.bestpractices.dev/projects/6505" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/9474bf3f648febb60677273a911b82e1d3ac8142af8668e65de89ca8cd3cb5a6/68747470733a2f2f7777772e626573747072616374696365732e6465762f70726f6a656374732f363530352f6261646765" alt="OpenSSF Best Practices"&gt;&lt;/a&gt;
&lt;a href="https://scorecard.dev/viewer/?uri=github.com/lima-vm/lima" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://camo.githubusercontent.com/ab44d38449794e0ffb058205e946e88bd254f6194a58981cb360a63d12812369/68747470733a2f2f6170692e73636f7265636172642e6465762f70726f6a656374732f6769746875622e636f6d2f6c696d612d766d2f6c696d612f6261646765" alt="OpenSSF Scorecard"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://lima-vm.io/" rel="nofollow noopener noreferrer"&gt;Lima&lt;/a&gt; launches Linux virtual machines with automatic file sharing and port forwarding (similar to WSL2).&lt;/p&gt;
&lt;p&gt;The original goal of Lima was to promote &lt;a href="https://containerd.io" rel="nofollow noopener noreferrer"&gt;containerd&lt;/a&gt; including &lt;a href="https://github.com/containerd/nerdctl" rel="noopener noreferrer"&gt;nerdctl (contaiNERD ctl)&lt;/a&gt;
to Mac users, but Lima can be used for non-container applications as well.&lt;/p&gt;
&lt;p&gt;Lima also supports other container engines (Docker, Podman, Kubernetes, etc.) and non-macOS hosts (Linux, NetBSD, etc.).&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Getting started&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;Set up (on macOS):&lt;/p&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;brew install lima
limactl start&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;To run Linux commands:&lt;/p&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;lima sudo apt-get install -y neofetch
lima neofetch&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;To run containers with containerd:&lt;/p&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;lima nerdctl run --rm hello-world&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;To run containers with Docker:&lt;/p&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;limactl start template://docker
&lt;span class="pl-k"&gt;export&lt;/span&gt; DOCKER_HOST=&lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;$(&lt;/span&gt;limactl list docker --format &lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;unix://{{.Dir}}/sock/docker.sock&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;span class="pl-pds"&gt;)&lt;/span&gt;&lt;/span&gt;
docker run --rm hello-world&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;To run containers with Kubernetes:&lt;/p&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;limactl start template://k8s
&lt;span class="pl-k"&gt;export&lt;/span&gt; KUBECONFIG=&lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;$(&lt;/span&gt;limactl list k8s --format &lt;span class="pl-s"&gt;&lt;span class="pl-pds"&gt;'&lt;/span&gt;unix://{{.Dir}}/copied-from-guest/kubeconfig.yaml&lt;span class="pl-pds"&gt;'&lt;/span&gt;&lt;/span&gt;&lt;span class="pl-pds"&gt;)&lt;/span&gt;&lt;/span&gt;
kubectl apply&lt;/pre&gt;…
&lt;/div&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/lima-vm/lima" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br&gt;
Or at least Lima and all of the tools it pulls together like Rosetta, QEMU, containerd, nerdctl, etc. Lima is virtual machine from which you can launch containers using the containerd runtime (or the docker runtime if you so choose). 

&lt;p&gt;Virtual machines can be launched on the battle-hardened QEMU emulator, or more importantly for our use case, using native virtualisation, aka VZ (to Lima) or Rosetta 2. While still experimental the VZ virtual machine type offers better performance and is the only VM I could get SQL Server to work on.&lt;/p&gt;
&lt;h2&gt;
  
  
  SQL Server on Apple Silicon
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Get it going
&lt;/h3&gt;

&lt;p&gt;To get SQL Server running, first download and install Lima using Homebrew (other installation options can be &lt;a href="https://github.com/lima-vm/lima#getting-started" rel="noopener noreferrer"&gt;found on GitHub&lt;/a&gt;):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install lima
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once installed, start a new virtual machine using the experimental VZ VM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;limactl start --name=default --tty=false template://experimental/vz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above command will create a new VM config under &lt;code&gt;$HOME/.lima/default&lt;/code&gt;. By using default we get the convenience of not having to name our VM for shell commands. &lt;code&gt;--tty=false&lt;/code&gt; is not necessary, it is just a convenient way to skip Lima asking if you want to review your config.&lt;/p&gt;

&lt;p&gt;You should see an output for the starting VM concluding with the following lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;INFO[0040] [hostagent] Waiting for the final requirement 1 of 1: "boot scripts must have finished"
INFO[0049] [hostagent] The final requirement 1 of 1 is satisfied
INFO[0049] READY. Run `lima` to open the shell.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you happen to see the error &lt;code&gt;r.CreateEndpoint() = connection was refused&lt;/code&gt; along the way this can safely be ignored.&lt;/p&gt;

&lt;p&gt;Now that the VM is running, all that is left to do is start a SQL Server container. This can be done using nerdCtl, a CLI tool for containerd that mimics the commands available in the Docker CLI.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nerdctl.lima run --platform linux/amd64 -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=ThisIsMyP@ssw0rdThereAreManyLikeItButThisOneIsMine" -p 1433:1433 -d --restart always mcr.microsoft.com/mssql/server:2022-latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will launch SQL Server on the necessary amd64 runtime, accepting the EULA and setting the &lt;code&gt;sa&lt;/code&gt; password in the process. It exposes the SQL Server default port 1433 and is configured to run in the background and restart if stopped.&lt;/p&gt;

&lt;p&gt;If SQL Server 2022 isn't your jam then just replace the container tag with the SQL Server version of your choosing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nerdctl.lima run --platform linux/amd64 -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=ThisIsMyP@ssw0rdThereAreManyLikeItButThisOneIsMine" -p 1433:1433 -d --restart always mcr.microsoft.com/mssql/server:2019-latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, obtain the IP address of the running VM using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lima ip -f inet addr
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The IP address you are after will be listed under the &lt;code&gt;lima0&lt;/code&gt; adaptor.&lt;/p&gt;

&lt;h3&gt;
  
  
  Test it works
&lt;/h3&gt;

&lt;p&gt;One simple way to test if SQL Server is running and accessible is to use Microsoft's &lt;code&gt;sqlcmd&lt;/code&gt; tool. This can also be installed with Homebrew:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
brew update
brew install mssql-tools
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then attempt to connect:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sqlcmd -S 192.168.105.3 -U sa -P "ThisIsMyP@ssw0rdThereAreManyLikeItButThisOneIsMine" -Q "select name,database_id,create_date from sys.databases"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;-S&lt;/code&gt; refers to the server address. This is the IP address of the VM that you obtained earlier.&lt;/p&gt;

&lt;p&gt;If all has gone to plan you should see the databases that currently belong to SQL Server along with their ID and create date.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cleaning up
&lt;/h3&gt;

&lt;p&gt;If you need to clean up your Lima VM for any reason, first stop the VM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;limactl stop default
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then delete it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;limactl delete default
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Final disclaimer
&lt;/h2&gt;

&lt;p&gt;Lima is still quite new and I am even newer to it so bear in mind that there may be better ways to wield this weapon. There is also a lot of development in this space with the likes of &lt;a href="https://github.com/runfinch/finch" rel="noopener noreferrer"&gt;Finch&lt;/a&gt;, &lt;a href="https://multipass.run" rel="noopener noreferrer"&gt;Multipass&lt;/a&gt; and others offering potential alternatives or simplifications to this approach so watch this space! &lt;/p&gt;

</description>
      <category>ai</category>
      <category>computerscience</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
