{"id":2333,"date":"2020-12-10T17:38:38","date_gmt":"2020-12-10T16:38:38","guid":{"rendered":"https:\/\/denbeke.be\/blog\/?p=2333"},"modified":"2021-01-24T16:42:46","modified_gmt":"2021-01-24T15:42:46","slug":"using-docker-on-an-m1-mac-by-running-docker-on-an-old-intel-mac","status":"publish","type":"post","link":"https:\/\/denbeke.be\/blog\/mac\/using-docker-on-an-m1-mac-by-running-docker-on-an-old-intel-mac\/","title":{"rendered":"Using Docker on an M1 Mac by running Docker on an old Intel Mac"},"content":{"rendered":"\n<p><strong>EDIT:<\/strong> There is now a <a rel=\"noreferrer noopener\" href=\"https:\/\/docs.docker.com\/docker-for-mac\/apple-m1\/\" target=\"_blank\">Docker technical preview<\/a> for M1 Macs. I checked it out, and it&#8217;s way more useful than this guide!<\/p>\n\n\n\n<p>This guide is for you if you jumped on the Apple Silicon bandwagon and bought yourself a fancy new M1 Mac, but you need Docker from time to time.<\/p>\n\n\n\n<p>It describes how I use an old Intel Mac as Docker host that runs all the Docker commands from my M1 MacBook Air. <em>(You can use any remote Docker host for this, but for my setup an old Mac was more convenient.)<\/em><\/p>\n\n\n\n<h3 id=\"install-docker\">Install Docker<\/h3>\n\n\n\n<p><strong>M1 (Apple Silicon) Mac:<\/strong> On your M1 Mac you should only install the Docker client. Since the Docker runtime won\u2019t work on it (yet). Head over to the official Docker documentation if you haven\u2019t go the client yet: <a href=\"https:\/\/docs.docker.com\/engine\/install\/binaries\/#install-client-binaries-on-macos\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/docs.docker.com\/engine\/install\/binaries\/#install-client-binaries-on-macos<\/a><\/p>\n\n\n\n<p><strong>Intel Mac:<\/strong> On the Intel Mac you can follow the usual Docker installation guide: <a href=\"https:\/\/docs.docker.com\/docker-for-mac\/install\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/docs.docker.com\/docker-for-mac\/install\/<\/a>. In short: Download and follow the installation instructions in the <code>.dmg<\/code>.<\/p>\n\n\n\n<h3 id=\"enable-ssh-access-on-the-old-mac\">Enable SSH access on the old Mac<\/h3>\n\n\n\n<p>First you need to enable SSH. To do so, open <em>System Preferences<\/em> and go to <em>Sharing<\/em>.<\/p>\n\n\n\n<p>Check the checkbox next to <em>Remote Login<\/em> to enable SSH.<\/p>\n\n\n\n<p>In the same window I also set the computer name to something simple: e.g.&nbsp;<code>mbp<\/code>. That way I can easily access the machine on my local networking using: <code>ssh myname@mbp.local<\/code>. Or <code>http:\/\/mbp.local\/<\/code> for Docker services.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"843\" src=\"https:\/\/denbeke.be\/blog\/wp-content\/uploads\/2020\/12\/macOS-System-Preferences-enable-SSH-access-1024x843.png\" alt=\"Screenshot 2020-12-10 at 16.01.13\" class=\"wp-image-2334\" srcset=\"https:\/\/denbeke.be\/blog\/wp-content\/uploads\/2020\/12\/macOS-System-Preferences-enable-SSH-access-1024x843.png 1024w, https:\/\/denbeke.be\/blog\/wp-content\/uploads\/2020\/12\/macOS-System-Preferences-enable-SSH-access-300x247.png 300w, https:\/\/denbeke.be\/blog\/wp-content\/uploads\/2020\/12\/macOS-System-Preferences-enable-SSH-access-768x632.png 768w, https:\/\/denbeke.be\/blog\/wp-content\/uploads\/2020\/12\/macOS-System-Preferences-enable-SSH-access-1536x1264.png 1536w, https:\/\/denbeke.be\/blog\/wp-content\/uploads\/2020\/12\/macOS-System-Preferences-enable-SSH-access.png 1560w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>In order to do passwordless login between the two Macs, you have to copy your public key to the old Mac.<\/p>\n\n\n\n<p>First you have to generate a new key:<\/p>\n\n\n\n<pre class=\"wp-block-code bash\"><code>ssh-keygen<\/code><\/pre>\n\n\n\n<p>Just hit enter to autofill all the inputs.<\/p>\n\n\n\n<p>Now copy the public key to the other Mac:<\/p>\n\n\n\n<pre class=\"wp-block-code bash\"><code>cat ~\/.ssh\/id_dsa.pub | ssh your-user@mbp.local 'cat >> ~\/.ssh\/authorized_keys'<\/code><\/pre>\n\n\n\n<p>This one time you will have to input your password manually.<\/p>\n\n\n\n<p>If this step was successful, you can now SSH into the machine without entering your password. Try it out like this:<\/p>\n\n\n\n<pre class=\"wp-block-code bash\"><code>ssh your-user@mbp.local<\/code><\/pre>\n\n\n\n<p>\u2139\ufe0f Checkout this guide if you need for info: <a href=\"https:\/\/osxdaily.com\/2012\/05\/25\/how-to-set-up-a-password-less-ssh-login\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/osxdaily.com\/2012\/05\/25\/how-to-set-up-a-password-less-ssh-login\/<\/a><\/p>\n\n\n\n<h3 id=\"enabling-ssh-environments-for-docker-context\">Enabling SSH Environments for Docker context<\/h3>\n\n\n\n<p>To allow Docker context to find the <code>docker<\/code> command on the remote machine, you have to configure the <code>$PATH<\/code> of the SSH sessions:<\/p>\n\n\n\n<p>Edit the <code>\/etc\/ssh\/sshd_config<\/code> file on the old Mac.<\/p>\n\n\n\n<p>Uncomment the <code>#PermitUserEnvironment no<\/code> line and change it to <code>PermitUserEnvironment yes<\/code><\/p>\n\n\n\n<p>Then restart SSH by unchecking and checking the checkbox next to <em>Remote Login<\/em> in <em>System Preferences<\/em>, <em>Sharing<\/em>.<\/p>\n\n\n\n<p>Then create a new file<code>~\/.ssh\/environment<\/code> with the following content:<\/p>\n\n\n\n<pre class=\"wp-block-code bash\"><code>PATH=$PATH:\/usr\/local\/bin<\/code><\/pre>\n\n\n\n<p>\u2139\ufe0f Checkout this Github issue for more info: <a href=\"https:\/\/github.com\/docker\/for-mac\/issues\/4382#issuecomment-603031242\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/docker\/for-mac\/issues\/4382#issuecomment-603031242<\/a><\/p>\n\n\n\n<h3 id=\"using-the-docker-environment-from-the-intel-mac-on-your-new-m1-mac\">Using the Docker environment from the Intel Mac on your new M1 Mac<\/h3>\n\n\n\n<p>Last thing to do is configuring our Docker command on the M1 Mac to use the old Intel Mac. For this, we use <a href=\"https:\/\/docs.docker.com\/engine\/context\/working-with-contexts\/\" target=\"_blank\" rel=\"noreferrer noopener\">Docker context<\/a>.<\/p>\n\n\n\n<p>First you have to create a new context:<\/p>\n\n\n\n<pre class=\"wp-block-code bash\"><code>docker context create my-old-mac --docker \"host=ssh:\/\/your-user@mbp.local\"<\/code><\/pre>\n\n\n\n<p>Then you can activate it using:<\/p>\n\n\n\n<pre class=\"wp-block-code bash\"><code>docker context use my-old-mac<\/code><\/pre>\n\n\n\n<p>Now you should be able to run a test container on your M1 Mac, which is actually run on your old Intel Mac behind the scenes:<\/p>\n\n\n\n<pre class=\"wp-block-code bash\"><code>docker run hello-world<\/code><\/pre>\n\n\n\n<p>Don\u2019t forget that if you run webservices with Docker on the old Mac, that you can\u2019t access them via <code>localhost<\/code>, but that you have to use the hostname of the Mac where Docker is running: <code>mbp.local<\/code><\/p>\n\n\n\n<h3 id=\"conclusion\">Conclusion<\/h3>\n\n\n\n<p>It isn\u2019t rocket science to run Docker on your old Mac, but it\u2019s not the most pratical solution.<br>So let\u2019s hope that the Apple Sillicon Macs get Docker support soon!<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>EDIT: There is now a Docker technical preview for M1 Macs. I checked it out, and it&#8217;s way more useful than this guide! This guide is for you if you jumped on the Apple Silicon bandwagon and bought yourself a fancy new M1 Mac, but you need Docker from time to time. It describes how [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[114,122],"tags":[286,125,287,151,186,253],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v15.6.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Using Docker on an M1 Mac by running Docker on an old Intel Mac &ndash; DenBeke<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/denbeke.be\/blog\/mac\/using-docker-on-an-m1-mac-by-running-docker-on-an-old-intel-mac\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using Docker on an M1 Mac by running Docker on an old Intel Mac &ndash; DenBeke\" \/>\n<meta property=\"og:description\" content=\"EDIT: There is now a Docker technical preview for M1 Macs. I checked it out, and it&#8217;s way more useful than this guide! This guide is for you if you jumped on the Apple Silicon bandwagon and bought yourself a fancy new M1 Mac, but you need Docker from time to time. It describes how [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/denbeke.be\/blog\/mac\/using-docker-on-an-m1-mac-by-running-docker-on-an-old-intel-mac\/\" \/>\n<meta property=\"og:site_name\" content=\"DenBeke\" \/>\n<meta property=\"article:published_time\" content=\"2020-12-10T16:38:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-01-24T15:42:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/denbeke.be\/blog\/wp-content\/uploads\/2020\/12\/macOS-System-Preferences-enable-SSH-access-1024x843.png\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<meta name=\"twitter:creator\" content=\"@MthsBk\" \/>\n<meta name=\"twitter:site\" content=\"@MthsBk\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"3 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/denbeke.be\/blog\/#website\",\"url\":\"https:\/\/denbeke.be\/blog\/\",\"name\":\"DenBeke\",\"description\":\"Mathias Beke\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/denbeke.be\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/denbeke.be\/blog\/mac\/using-docker-on-an-m1-mac-by-running-docker-on-an-old-intel-mac\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/denbeke.be\/blog\/wp-content\/uploads\/2020\/12\/macOS-System-Preferences-enable-SSH-access.png\",\"width\":1560,\"height\":1284},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/denbeke.be\/blog\/mac\/using-docker-on-an-m1-mac-by-running-docker-on-an-old-intel-mac\/#webpage\",\"url\":\"https:\/\/denbeke.be\/blog\/mac\/using-docker-on-an-m1-mac-by-running-docker-on-an-old-intel-mac\/\",\"name\":\"Using Docker on an M1 Mac by running Docker on an old Intel Mac &ndash; DenBeke\",\"isPartOf\":{\"@id\":\"https:\/\/denbeke.be\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/denbeke.be\/blog\/mac\/using-docker-on-an-m1-mac-by-running-docker-on-an-old-intel-mac\/#primaryimage\"},\"datePublished\":\"2020-12-10T16:38:38+00:00\",\"dateModified\":\"2021-01-24T15:42:46+00:00\",\"author\":{\"@id\":\"https:\/\/denbeke.be\/blog\/#\/schema\/person\/386878f712fe3fe22227216f087772dc\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/denbeke.be\/blog\/mac\/using-docker-on-an-m1-mac-by-running-docker-on-an-old-intel-mac\/\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/denbeke.be\/blog\/#\/schema\/person\/386878f712fe3fe22227216f087772dc\",\"name\":\"Mathias Beke\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/denbeke.be\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/015ba35e6ce4f5859e3888ca99807575?s=96&d=mm&r=g\",\"caption\":\"Mathias Beke\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/posts\/2333"}],"collection":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/comments?post=2333"}],"version-history":[{"count":2,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/posts\/2333\/revisions"}],"predecessor-version":[{"id":2349,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/posts\/2333\/revisions\/2349"}],"wp:attachment":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/media?parent=2333"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/categories?post=2333"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/tags?post=2333"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}