{"id":3989,"date":"2022-11-28T17:49:10","date_gmt":"2022-11-28T17:49:10","guid":{"rendered":"https:\/\/www.gubatron.com\/blog\/?p=3989"},"modified":"2022-11-28T17:51:02","modified_gmt":"2022-11-28T17:51:02","slug":"how-to-build-your-docker-image-using-the-same-dockerfile-regardless-of-the-host-architecture","status":"publish","type":"post","link":"https:\/\/www.gubatron.com\/blog\/how-to-build-your-docker-image-using-the-same-dockerfile-regardless-of-the-host-architecture\/","title":{"rendered":"How to build your Docker image using the same Dockerfile regardless of the host architecture"},"content":{"rendered":"<h2>Problem<\/h2>\n<p>If you are now using docker on a Mac M1 (<code>arm64<\/code> platform), you don&#8217;t want to use <code>amd64<\/code> as the architecture for your Linux Images.<\/p>\n<p>You could have 2 lines on your <code>Dockerfile<\/code> and comment each one depending on where you&#8217;re building the image<\/p>\n<p>Dockerfile<\/p>\n<pre><code># Building on Apple Silicon host\nFROM --platform=linux\/arm64 ubuntu:20.04\n\n# Building on Intel\/x86_64 host\n#FROM --platform=linux\/amd64 ubuntu:20.04\n<\/code><\/pre>\n<p><strong>Eventually this becomes very annoying.<\/strong><\/p>\n<h2>Solution<\/h2>\n<p>You can pass a build time argument when you invoke docker build<\/p>\n<p>Put this on your Dockerfile:<\/p>\n<pre><code>ARG BUILDPLATFORM\nFROM --platform=linux\/$BUILDPLATFORM ubuntu:20.04\n<\/code><\/pre>\n<p>On your <code>docker_build_image.sh<\/code> script:<\/p>\n<pre><code>export BUILDPLATFORM=`uname -m`\ndocker build --build-arg BUILDPLATFORM=${BUILDPLATFORM} -t myimagename .\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Problem If you are now using docker on a Mac M1 (arm64 platform), you don&#8217;t want to use amd64 as the architecture for your Linux Images. You could have 2 lines on your Dockerfile and comment each one depending on where you&#8217;re building the image Dockerfile # Building on Apple Silicon host FROM &#8211;platform=linux\/arm64 ubuntu:20.04 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[15,43,45],"tags":[1656,1657,1655,1658],"class_list":["post-3989","post","type-post","status-publish","format-standard","hentry","category-code","category-linux","category-mac-osx","tag-apple-silicon","tag-apple-sillicon","tag-docker","tag-dockerfile"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5Unzf-12l","jetpack-related-posts":[{"id":175,"url":"https:\/\/www.gubatron.com\/blog\/linux-ubuntu-finally-arrived\/","url_meta":{"origin":3989,"position":0},"title":"Linux Ubuntu finally arrived.","author":"gubatron","date":"June 29, 2005","format":false,"excerpt":"Ubuntu Linux from Netherlands finally delivered the copies I ordered for you guys. After taking my copies and giving some to my friends, I have the following in Inventory for those who are interested: -> 9 Ubuntu Linux 5.04 for Intel x86 -> 1 Ubuntu Linux 5.04 for AMD64\/EM64T ->\u2026","rel":"","context":"In &quot;Gubatron&quot;","block_context":{"text":"Gubatron","link":"https:\/\/www.gubatron.com\/blog\/category\/gubatron\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":351,"url":"https:\/\/www.gubatron.com\/blog\/instalar-linux-ubuntu-es-mas-fcil-y-rpido-que-instalar-windows-xp\/","url_meta":{"origin":3989,"position":1},"title":"Instalar Linux Ubuntu es mas f\u00e1cil y r\u00e1pido que instalar Windows XP","author":"gubatron","date":"July 28, 2006","format":false,"excerpt":"Sin tener nada puedes meter el CD de instalacion y ver si funciona, sin tener que instalarlo, luego puedes correr el CD desde ahi. No entiendes? Observa. La instalacion dura aproximadamente unos 20 a 25 minutos en un AMD64 de 2.0Ghz.","rel":"","context":"In &quot;Geeklife&quot;","block_context":{"text":"Geeklife","link":"https:\/\/www.gubatron.com\/blog\/category\/geeklife\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1336,"url":"https:\/\/www.gubatron.com\/blog\/compiling-ghost-white-crab-on-linux-x86_64-ubuntu-linux\/","url_meta":{"origin":3989,"position":2},"title":"Compiling Ghost White Crab on Linux x86_64 Ubuntu Linux","author":"gubatron","date":"July 26, 2009","format":false,"excerpt":"Compiling this software is usually just a matter of running 'make', but if you try to do so in Ubuntu 64bit, you'll encounter the following error on the config_test.log file skipping incompatible \/usr\/lib\/gcc\/x86_64-linux-gnu\/4.3.3\/libgcc.a when searching for -lgcc To solve this issue just do the following: apt-get install libc6-dev-i386 This makes\u2026","rel":"","context":"In &quot;Geeklife&quot;","block_context":{"text":"Geeklife","link":"https:\/\/www.gubatron.com\/blog\/category\/geeklife\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3453,"url":"https:\/\/www.gubatron.com\/blog\/command-line-speed-test-see-how-fast-is-your-servers-connection\/","url_meta":{"origin":3989,"position":3},"title":"command line speed test, see how fast is your server&#8217;s connection","author":"gubatron","date":"January 6, 2016","format":false,"excerpt":"Save the following script in a file called speed_test #!\/bin\/bash # Requirements # sudo apt-get install lftp iperf lftp -e 'pget http:\/\/releases.ubuntu.com\/14.04.3\/ubuntu-14.04.3-desktop-amd64.iso; exit; ' make sure the file is executable: sudo chmod +x speed_test Once you have installed lftp and iperf make sure you have the script somewhere in your\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2016\/01\/Fiber-optics.jpg?fit=892%2C538&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2016\/01\/Fiber-optics.jpg?fit=892%2C538&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2016\/01\/Fiber-optics.jpg?fit=892%2C538&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2016\/01\/Fiber-optics.jpg?fit=892%2C538&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":374,"url":"https:\/\/www.gubatron.com\/blog\/mac-os-x-on-dual-screen-ubuntu-kde-via-vnc\/","url_meta":{"origin":3989,"position":4},"title":"Mac OS X on Dual Screen Ubuntu (KDE) via VNC","author":"gubatron","date":"September 20, 2006","format":false,"excerpt":"mac_os_en_dual_screen_ubuntu_via_vnc.JPG Originally uploaded by Gubatron. So now I don't have to move my chair to the desk where I got the mac, my linux box is my control station. And I can even run windows, since the mac runs parallels. Sweet. 3 OS in one... I mean 2 screens. :)","rel":"","context":"In &quot;Geeklife&quot;","block_context":{"text":"Geeklife","link":"https:\/\/www.gubatron.com\/blog\/category\/geeklife\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3899,"url":"https:\/\/www.gubatron.com\/blog\/how-to-suppress-useless-mod_openssl-lighttpd-error-messages-from-var-log-syslog-in-ubuntu\/","url_meta":{"origin":3989,"position":5},"title":"[linux\/ubuntu] How to suppress useless mod_openssl\/lighttpd error messages from appearing in \/var\/log\/syslog","author":"gubatron","date":"August 7, 2020","format":false,"excerpt":"Sometimes you have a bunch of useless errors creating unnecessary disk I\/O on your server, disk I\/O that should be used towards serving your user's requests efficiently. In this case a site running on lighttpd keeps logging several times per second the following message, creating too much noise and making\u2026","rel":"","context":"In &quot;Linux&quot;","block_context":{"text":"Linux","link":"https:\/\/www.gubatron.com\/blog\/category\/linux\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3989","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/comments?post=3989"}],"version-history":[{"count":5,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3989\/revisions"}],"predecessor-version":[{"id":3994,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3989\/revisions\/3994"}],"wp:attachment":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/media?parent=3989"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/categories?post=3989"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/tags?post=3989"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}