{
  "attachments": [
    "./vscode-docker-web-ui-3.png",
    "./vscode-devel-container.png",
    "./vscode-docker-terminal.png",
    "./vscode-docker-contexts-use-1.png",
    "./vscode-docker-context-select.png",
    "./vscode-docker-context-selected.png",
    "./vscode-docker-containers-3.png",
    "./vscode-editing-blog.png",
    "./vscode-file-station.png",
    "./vscode-ds210j-nas.png",
    "./vscode-ds723-plus.png",
    "./castiel.gif"
  ],
  "title": "Synology + Docker + VSCode",
  "tags": [
    "synology",
    "docker",
    "vscode",
    "tinkering",
    "nas"
  ],
  "year": "2023",
  "month": "01",
  "day": "31",
  "isDir": true,
  "slug": "synology-docker-vscode",
  "type": "entry",
  "date": "2023-01-31T19:00:00.000Z",
  "postName": "2023-01-31-synology-docker-vscode",
  "html": "<p><strong>TL;DR</strong>: My new Synology NAS supports Docker and I can connect to it with VSCode for tinkering with all my horrible projects!</p>\n<!--more-->\n\n\n\n<p>Over the past couple of decades, I've had a Linux box kicking around on a basement shelf. It's a Ship of Theseus, composed of parts filtering out of my gaming PC after upgrades. This box tends to host my random experiments and learning projects - and it also tends to be broken in some way or another. That's fun for tinkering, but frustrating for things I want to stay working in between bouts of tinkering.</p>\n<img src=\"./vscode-ds210j-nas.png\" alt=\"Synology DS210j\" class=\"inset left\" width=\"\" height=\"\">\n\n<p>Enter my discovery of low-end Synology NAS devices: They're tidy little things, like the size of two Nintendo Wii taped together.</p>\n<p>My first was a <a href=\"https://global.download.synology.com/download/Document/Hardware/DataSheet/DiskStation/10-year/DS210j/enu/Synology_DS210j_Data_Sheet_enu.pdf\">DS210j</a> in 2010, followed by a <a href=\"https://global.download.synology.com/download/Document/Hardware/DataSheet/DiskStation/14-year/DS214play/enu/Synology_DS214play_Data_Sheet_enu.pdf\">DS214play</a> in 2015. They reliably take on the boring jobs that I've gotten tired of maintaining on my perpetually janky hobby server.</p>\n<img src=\"./vscode-ds723-plus.png\" alt=\"Synology DS723+\" class=\"inset right\" width=\"\" height=\"\">\n\n<p>And then, just this week, I acquired a <a href=\"https://global.download.synology.com/download/Document/Hardware/DataSheet/DiskStation/23-year/DS723%2B/enu/Synology_DS723%2B_Data_Sheet_enu.pdf\">DS723+</a> . This one is quite an upgrade: My first NAS had 128MB of RAM and the second sported 2GB. This latest one has been upgraded with a whole 32GB. Along with that, I've slapped in a pair of  <a href=\"https://www.newegg.com/seagate-ironwolf-st10000vn000-10tb/p/N82E16822184973?Item=N82E16822184973\">10TB IronWolf hard drives</a> in a RAID1 configuration.</p>\n<p>Beyond backups and media storage, why bother with all that for just a NAS? Well, this one supports Docker. And, as it turns out, a great many of my tinkering projects fit nicely into Docker containers.</p>\n<p>So, in other words, it appears that this latest NAS can even take on the boring job of hosting <em>many</em> janky little hobby servers - virtually! This, while continuing to reliably do everything else a Synology NAS does. </p>\n<p><img src=\"./vscode-docker-web-ui-3.png\" alt=\"\" width=\"\" height=\"\"></p>\n<p>With Docker containers, I don't have to try crapping up the Synology host OS with attempts at installing assorted programming languages and tools (ahem, <a href=\"https://en.wikipedia.org/wiki/Optware\">optware</a>). </p>\n<p>I have a long history of ill-advised attempts to turn a NAS into a dev machine, going all the way back to the <a href=\"https://en.wikipedia.org/wiki/NSLU2\">Linksys NSLU2</a>, circa 2004. But, if I crap up a Docker container, I can toss it and rebuild without disturbing, say, <a href=\"https://www.silicondust.com/dvr-service/\">the DVR</a> for my TV antenna or <a href=\"https://tt-rss.org/\">the self-hosted RSS reader</a> we use at home.</p>\n<p><img src=\"./vscode-devel-container.png\" alt=\"\" width=\"\" height=\"\"></p>\n<p>The web UI even has a cute little in-browser terminal for access to the container:</p>\n<p><img src=\"./vscode-docker-terminal.png\" alt=\"\" width=\"\" height=\"\"></p>\n<p>Of course, I'll likely find limits to this. I can imagine there'll be some tinkery projects I don't want moshing around on the thing that lets us watch Seinfeld reruns after dinner. I'll still have my Ship of Theseus on hand for that stuff. But, that still leaves a great many things I can just toss onto the Synology for fun.</p>\n<p>And speaking of my network, I just discovered how to <a href=\"https://code.visualstudio.com/docs/containers/ssh\">connect VSCode via SSH to a Docker container on a remote host</a> - i.e. my shiny new Synology DS723+ server. This makes for a kind of fiddly self-hosted alternative to <a href=\"https://github.com/features/codespaces\">GitHub Codespaces</a> in my basement.</p>\n<p>Key to this are <a href=\"https://docs.docker.com/engine/context/working-with-contexts/\">Docker contexts</a> - they've been around for a few years, and I've likely been using tools that use them, but I hadn't really learned about them until this week. Long story short, I can switch <code>docker</code> on my Mac laptop over to managing Docker on my NAS like so:</p>\n<pre><code>docker context create castiel --docker \"host=ssh://lmorchard@castiel\"\ndocker context use castiel\ndocker ps\n</code></pre>\n<p>(Yes, I named my new server \"<a href=\"https://supernatural.fandom.com/wiki/Castiel\">Castiel</a>\" after <a href=\"https://supernatural.fandom.com/wiki/Castiel\">the angel from Supernatural</a>. Watching over our files, he'd probably think we've hoarded too many episodes of Frasier and Star Trek.)</p>\n<img src=\"./castiel.gif\" width=\"\" height=\"\">\n\n<p>Anyway, once I have a new working Docker context defined, I can access it from VSCode for tinkering. First thing is to select the Docker context. On my Mac, that means hitting Command-Shift-P and typing \"<code>dockeru</code>\" until the <code>Docker Contexts: Use</code> command appears:</p>\n<p><img src=\"./vscode-docker-contexts-use-1.png\" alt=\"\" width=\"\" height=\"\"></p>\n<p>Selecting that gives me a selection of contexts, which includes <code>castiel</code>:</p>\n<p><img src=\"./vscode-docker-context-select.png\" alt=\"\" width=\"\" height=\"\"></p>\n<p>I pick that, and VSCode confirms the selection:</p>\n<p><img src=\"./vscode-docker-context-selected.png\" alt=\"\" width=\"\" height=\"\">\nNow, when I click on Remote Explorer in the sidebar here, all the running containers on my Synology soon appear. From here, I can click on the \"Attach to Container\" button:</p>\n<p><img src=\"./vscode-docker-containers-3.png\" alt=\"\" width=\"\" height=\"\"></p>\n<p>Once attached, I can add a folder from the container and start tinkering away on this very blog post!</p>\n<p><img src=\"./vscode-editing-blog.png\" alt=\"\" width=\"\" height=\"\"></p>\n<p>Oh yeah, and since this is Docker, I can mount a path from the host NAS as storage for all my project code outside of the disposable container:</p>\n<p><img src=\"./vscode-file-station.png\" alt=\"\" width=\"\" height=\"\"></p>\n<p>I know there can be some problems with this, I think largely around file watchers and suchlike. But, I'll burn those bridges when I get to them. For now, this seems like a fun new toy to play with and it's off-loaded a few more little jobs from my junker PC. </p>\n<p>Maybe next I can reformat the hobby server and try some more advanced things like <a href=\"https://www.proxmox.com/en/\">Proxmox</a> and friends, so it'll be like a big sibling to the little Synology.</p>\n",
  "body": "**TL;DR**: My new Synology NAS supports Docker and I can connect to it with VSCode for tinkering with all my horrible projects!\n\n<!--more-->\n\nOver the past couple of decades, I've had a Linux box kicking around on a basement shelf. It's a Ship of Theseus, composed of parts filtering out of my gaming PC after upgrades. This box tends to host my random experiments and learning projects - and it also tends to be broken in some way or another. That's fun for tinkering, but frustrating for things I want to stay working in between bouts of tinkering.\n\n<img src=\"./vscode-ds210j-nas.png\" alt=\"Synology DS210j\" class=\"inset left\" />\n\nEnter my discovery of low-end Synology NAS devices: They're tidy little things, like the size of two Nintendo Wii taped together.\n\nMy first was a [DS210j](https://global.download.synology.com/download/Document/Hardware/DataSheet/DiskStation/10-year/DS210j/enu/Synology_DS210j_Data_Sheet_enu.pdf) in 2010, followed by a [DS214play](https://global.download.synology.com/download/Document/Hardware/DataSheet/DiskStation/14-year/DS214play/enu/Synology_DS214play_Data_Sheet_enu.pdf) in 2015. They reliably take on the boring jobs that I've gotten tired of maintaining on my perpetually janky hobby server.\n\n<img src=\"./vscode-ds723-plus.png\" alt=\"Synology DS723+\" class=\"inset right\" />\n\nAnd then, just this week, I acquired a [DS723+](https://global.download.synology.com/download/Document/Hardware/DataSheet/DiskStation/23-year/DS723%2B/enu/Synology_DS723%2B_Data_Sheet_enu.pdf) . This one is quite an upgrade: My first NAS had 128MB of RAM and the second sported 2GB. This latest one has been upgraded with a whole 32GB. Along with that, I've slapped in a pair of  [10TB IronWolf hard drives](https://www.newegg.com/seagate-ironwolf-st10000vn000-10tb/p/N82E16822184973?Item=N82E16822184973) in a RAID1 configuration.\n\nBeyond backups and media storage, why bother with all that for just a NAS? Well, this one supports Docker. And, as it turns out, a great many of my tinkering projects fit nicely into Docker containers.\n\nSo, in other words, it appears that this latest NAS can even take on the boring job of hosting *many* janky little hobby servers - virtually! This, while continuing to reliably do everything else a Synology NAS does. \n\n![](./vscode-docker-web-ui-3.png)\n\nWith Docker containers, I don't have to try crapping up the Synology host OS with attempts at installing assorted programming languages and tools (ahem, [optware](https://en.wikipedia.org/wiki/Optware)). \n\nI have a long history of ill-advised attempts to turn a NAS into a dev machine, going all the way back to the [Linksys NSLU2](https://en.wikipedia.org/wiki/NSLU2), circa 2004. But, if I crap up a Docker container, I can toss it and rebuild without disturbing, say, [the DVR](https://www.silicondust.com/dvr-service/) for my TV antenna or [the self-hosted RSS reader](https://tt-rss.org/) we use at home.\n\n![](./vscode-devel-container.png)\n\nThe web UI even has a cute little in-browser terminal for access to the container:\n\n![](./vscode-docker-terminal.png)\n\nOf course, I'll likely find limits to this. I can imagine there'll be some tinkery projects I don't want moshing around on the thing that lets us watch Seinfeld reruns after dinner. I'll still have my Ship of Theseus on hand for that stuff. But, that still leaves a great many things I can just toss onto the Synology for fun.\n\nAnd speaking of my network, I just discovered how to [connect VSCode via SSH to a Docker container on a remote host](https://code.visualstudio.com/docs/containers/ssh) - i.e. my shiny new Synology DS723+ server. This makes for a kind of fiddly self-hosted alternative to [GitHub Codespaces](https://github.com/features/codespaces) in my basement.\n\nKey to this are [Docker contexts](https://docs.docker.com/engine/context/working-with-contexts/) - they've been around for a few years, and I've likely been using tools that use them, but I hadn't really learned about them until this week. Long story short, I can switch `docker` on my Mac laptop over to managing Docker on my NAS like so:\n\n```\ndocker context create castiel --docker \"host=ssh://lmorchard@castiel\"\ndocker context use castiel\ndocker ps\n```\n\n(Yes, I named my new server \"[Castiel](https://supernatural.fandom.com/wiki/Castiel)\" after [the angel from Supernatural](https://supernatural.fandom.com/wiki/Castiel). Watching over our files, he'd probably think we've hoarded too many episodes of Frasier and Star Trek.)\n\n<img src=\"./castiel.gif\" />\n\nAnyway, once I have a new working Docker context defined, I can access it from VSCode for tinkering. First thing is to select the Docker context. On my Mac, that means hitting Command-Shift-P and typing \"`dockeru`\" until the `Docker Contexts: Use` command appears:\n\n![](./vscode-docker-contexts-use-1.png)\n\nSelecting that gives me a selection of contexts, which includes `castiel`:\n\n![](./vscode-docker-context-select.png)\n\nI pick that, and VSCode confirms the selection:\n\n![](./vscode-docker-context-selected.png)\nNow, when I click on Remote Explorer in the sidebar here, all the running containers on my Synology soon appear. From here, I can click on the \"Attach to Container\" button:\n\n![](./vscode-docker-containers-3.png)\n\nOnce attached, I can add a folder from the container and start tinkering away on this very blog post!\n\n![](./vscode-editing-blog.png)\n\nOh yeah, and since this is Docker, I can mount a path from the host NAS as storage for all my project code outside of the disposable container:\n\n![](./vscode-file-station.png)\n\nI know there can be some problems with this, I think largely around file watchers and suchlike. But, I'll burn those bridges when I get to them. For now, this seems like a fun new toy to play with and it's off-loaded a few more little jobs from my junker PC. \n\nMaybe next I can reformat the hobby server and try some more advanced things like [Proxmox](https://www.proxmox.com/en/) and friends, so it'll be like a big sibling to the little Synology.\n",
  "parentPath": "./content/posts/archives/2023/2023-01-31-synology-docker-vscode",
  "path": "2023/01/31/synology-docker-vscode",
  "thumbnail": "/2023/01/31/synology-docker-vscode/vscode-ds210j-nas.png",
  "summary": "TL;DR: My new Synology NAS supports Docker and I can connect to it with VSCode for tinkering with all my horrible projects!",
  "needsBuild": true,
  "prevPostPath": "2023/01/16/begging-for-treats",
  "prevPostTitle": "Begging for Treats",
  "nextPostPath": "2023/02/06/the-machine-is-grieving",
  "nextPostTitle": "The Machine is Grieving"
}