<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Docker on The Edge Cases</title>
    <link>https://www.kylestratis.com/tags/docker/</link>
    <description>Recent content in Docker on The Edge Cases</description>
    <generator>Hugo</generator>
    <language>en</language>
    <copyright>© 2025</copyright>
    <lastBuildDate>Fri, 18 Sep 2026 22:38:55 -0400</lastBuildDate>
    <atom:link href="https://www.kylestratis.com/tags/docker/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Building Docker Images on M1 Mac for Other Platforms</title>
      <link>https://www.kylestratis.com/notes/building-docker-images-on-m1-mac-for-other-platforms/</link>
      <pubDate>Sat, 19 Sep 2026 02:10:03 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/building-docker-images-on-m1-mac-for-other-platforms/</guid>
      <description>&lt;p&gt;In order to build Docker images for Lambda functions with CDK on ARM or other non-Intel platforms, but want the Lambda to be on an x86_64 platform, use the &lt;code&gt;platform&lt;/code&gt; parameter with the &lt;code&gt;from_image_asset()&lt;/code&gt; function.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;_lambda&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;DockerImage_function(&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;...&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    code&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;_lambda&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;DockerImageCode&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;from_image_asset(  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        directory&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;./lambda&amp;#34;&lt;/span&gt;,  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        file&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;./myservice/Dockerfile&amp;#34;&lt;/span&gt;,  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        platform&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;ecr_assets&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;Platform&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;LINUX_AMD64,  &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    ),&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;...&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;ecr_assets&lt;/code&gt; is a CDK package that also needs to be imported from the main &lt;code&gt;aws_cdk&lt;/code&gt; package.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Docker Run Issues - Unable to Start Container</title>
      <link>https://www.kylestratis.com/notes/docker-run-issues-unable-to-start-container/</link>
      <pubDate>Thu, 22 Feb 2024 15:40:37 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/docker-run-issues-unable-to-start-container/</guid>
      <description>&lt;p&gt;Sometimes you won&amp;rsquo;t be able to run a Docker container because some &lt;code&gt;.so&lt;/code&gt; file can&amp;rsquo;t be found. This is how to fix it:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;code&gt;sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;sudo rm -rf /var/lib/docker&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;sudo rm -rf /var/lib/containerd&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;sudo systemctl restart docker&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Rebuild and re-run image&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;Error message&lt;/p&gt;</description>
    </item>
    <item>
      <title>Running a Jupyter Notebook From a Docker Container Running on EC2</title>
      <link>https://www.kylestratis.com/notes/running-a-jupyter-notebook-from-a-docker-container-running-on-ec2/</link>
      <pubDate>Wed, 22 Nov 2023 21:54:06 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/running-a-jupyter-notebook-from-a-docker-container-running-on-ec2/</guid>
      <description>&lt;p&gt;Given a Dockerfile on an EC2 instance that has, at the very least, these commands at the end:&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;EXPOSE 8888&#xA;ENTRYPOINT [&amp;#34;/bin/bash&amp;#34;]&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;ol&gt;&#xA;&lt;li&gt;Build the image&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;docker build -t &amp;lt;image name&amp;gt; .&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;ol start=&#34;2&#34;&gt;&#xA;&lt;li&gt;Run the container&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;docker run -it -p 8888:8888 --ip=0.0.0.0 &amp;lt;image name&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If you want to persist data from the host to the container, include &lt;a href=&#34;https://www.kylestratis.com/notes/using-bind-mounts-to-speed-up-docker-development/&#34;&gt;bind mounts&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;docker run -it -p 8888:8888 -v /abs/path/to/data:/app/data --ip=0.0.0.0 &amp;lt;image name&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;ol start=&#34;3&#34;&gt;&#xA;&lt;li&gt;Within the container, run Jupyter Lab (note, specifying the port isn&amp;rsquo;t necessary if you&amp;rsquo;re using the default port 8888):&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;jupyter lab --port=8888 --ip=0.0.0.0 --allow-root&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;troubleshooting&#34;&gt;Troubleshooting&lt;/h2&gt;&#xA;&lt;p&gt;If you try to open Jupyter Lab in your browser, and you get a &amp;ldquo;refused to connect&amp;rdquo; error, ensure that the SSH config you have for your connection to your EC2 instance (or for SSH in general if you don&amp;rsquo;t have a specific entry for EC2) looks like this:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Working Within a Running Docker Container</title>
      <link>https://www.kylestratis.com/notes/working-within-a-running-docker-container/</link>
      <pubDate>Wed, 22 Nov 2023 02:34:18 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/working-within-a-running-docker-container/</guid>
      <description>&lt;p&gt;First, build your image (assuming your Dockerfile is in the current directory):&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;docker build -t myimg .&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Then call &lt;code&gt;run&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;docker run -it myimg&#xA;&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
    <item>
      <title>Using Bind Mounts to Speed Up Docker Development</title>
      <link>https://www.kylestratis.com/notes/using-bind-mounts-to-speed-up-docker-development/</link>
      <pubDate>Tue, 06 Jun 2023 20:41:50 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/using-bind-mounts-to-speed-up-docker-development/</guid>
      <description>&lt;p&gt;When using &lt;code&gt;docker run&lt;/code&gt;, the &lt;code&gt;--mount&lt;/code&gt; parameter allows you to specify a directory to recreate within the Docker container so that you can edit your code locally and then run it within the Docker container without rebuilding the image.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Consider whether coding &lt;a href=&#34;https://www.kylestratis.com/notes/remote-development-with-vs-code/#developing-with-docker&#34;&gt;within a running container&lt;/a&gt; fits your use case better.&lt;/p&gt;&lt;/blockquote&gt;&#xA;&lt;h2 id=&#34;example&#34;&gt;Example&lt;/h2&gt;&#xA;&lt;p&gt;&lt;code&gt;docker run -it --mount type=bind,source=&amp;quot;$(pwd)/tests&amp;quot;,target=/tests image_tag&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;This uses the &lt;code&gt;tests&lt;/code&gt; directory within the working directory as the source and puts the contents within a directory &lt;code&gt;/tests&lt;/code&gt; in the container whenever you call &lt;code&gt;docker run&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Remote Development with VS Code</title>
      <link>https://www.kylestratis.com/notes/remote-development-with-vs-code/</link>
      <pubDate>Tue, 06 Jun 2023 20:27:18 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/remote-development-with-vs-code/</guid>
      <description>&lt;h2 id=&#34;developing-with-docker&#34;&gt;Developing with Docker&lt;/h2&gt;&#xA;&lt;p&gt;To use Docker for developing in VS Code, you can use the Docker, Dev Containers and Remote Explorer extensions. Here&amp;rsquo;s a rough step-by-step guide:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Build an image if it hasn&amp;rsquo;t been built already from VS Code&lt;/li&gt;&#xA;&lt;li&gt;Right click the image and select &amp;ldquo;Run interactive&amp;rdquo;&lt;/li&gt;&#xA;&lt;li&gt;Then in the running container, right-click and run &amp;ldquo;Attach VS Code&amp;rdquo;&lt;/li&gt;&#xA;&lt;li&gt;A new VS Code window will open and you can select a directory within the container to open&#xA;You can also click the green icon in the lower left corner of the window to access the same options.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h2 id=&#34;developing-on-a-remote-server-with-ssh&#34;&gt;Developing on a Remote Server with SSH&lt;/h2&gt;&#xA;&lt;p&gt;To connect to a remote server and run VS Code on it, use the same Remote Explorer extension along with Remote - SSH:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Invalid Cross-Device Link when Deploying with CDK</title>
      <link>https://www.kylestratis.com/notes/invalid-cross-device-link-when-deploying-with-cdk/</link>
      <pubDate>Tue, 06 Jun 2023 20:20:58 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/invalid-cross-device-link-when-deploying-with-cdk/</guid>
      <description>&lt;p&gt;When deploying with CDK, I started out of nowhere getting this error:&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;OSError: [Errno 18] Invalid cross-device link: &amp;#39;/tmp/pip-target-e_4qns87/lib/python/numpy&amp;#39; -&amp;gt; &amp;#39;/asset-output/numpy&amp;#39;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This seems to be caused by using &lt;a href=&#34;https://stackoverflow.com/questions/64048687/why-does-serverless-produce-an-invalid-cross-device-link-error-when-trying-to-pa&#34;&gt;gRPC FUSE for file sharing&lt;/a&gt; in Docker. To fix this, change the setting for file sharing implemnentations from gRPC FUSE to VirtioFS.&lt;/p&gt;&#xA;&lt;p&gt;If this doesn&amp;rsquo;t work, it could imply a corrupted virtual environment. Build a new one and try again with that. This was what did the trick for me - but only for one deployment. Updating the few Python 3.8 lambda runtimes to 3.9 fixed it.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Logging from Custom Docker Code in Sagemaker</title>
      <link>https://www.kylestratis.com/notes/logging-from-custom-docker-code-in-sagemaker/</link>
      <pubDate>Tue, 10 Jan 2023 18:05:43 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/logging-from-custom-docker-code-in-sagemaker/</guid>
      <description>&lt;p&gt;Unlike in AWS Lambda code, in Sagemaker training jobs using custom Python code in Docker containers logging won&amp;rsquo;t work unless a stream handler is specifically added to the logger.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;logger &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; logging&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;getLogger(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;__main__&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;stream_handler &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; logging&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;StreamHandler(sys&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;stdout)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;logger&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;addHandler(stream_handler)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    <item>
      <title>SAGEMAKER_PROGRAM in Custom Dockerfile</title>
      <link>https://www.kylestratis.com/notes/sagemaker-program-in-custom-dockerfile/</link>
      <pubDate>Tue, 10 Jan 2023 03:47:47 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/sagemaker-program-in-custom-dockerfile/</guid>
      <description>&lt;p&gt;At the end of a Dockerfile that defines a container for a Sagemaker training job, you have to define the &lt;code&gt;SAGEMAKER_PROGRAM&lt;/code&gt; environment variable. It needs to point directly to the script that acts as the entry point as it exists within &lt;code&gt;/opt/ml/code&lt;/code&gt;, rather than the full path.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;ENV SAGEMAKER_PROGRAM train.py&lt;/code&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Deploying an Updated Image to Lambda Function</title>
      <link>https://www.kylestratis.com/notes/deploying-an-updated-image-to-lambda-function/</link>
      <pubDate>Wed, 04 Jan 2023 18:24:48 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/deploying-an-updated-image-to-lambda-function/</guid>
      <description>&lt;p&gt;Redeploying a CDK stack with a Lambda function that relies on a Docker image in ECR won&amp;rsquo;t necessarily update the function with a newly pushed image. Instead, use the Lambda console&amp;rsquo;s &amp;ldquo;Deploy new image&amp;rdquo; button to push the ECR image to the function.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Troubleshooting Slow Docker Image Builds</title>
      <link>https://www.kylestratis.com/notes/troubleshooting-slow-docker-image-builds/</link>
      <pubDate>Wed, 05 Oct 2022 14:31:11 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/troubleshooting-slow-docker-image-builds/</guid>
      <description>&lt;h2 id=&#34;slow-build-during-python-dependency-installation&#34;&gt;Slow Build During Python Dependency Installation&lt;/h2&gt;&#xA;&lt;p&gt;This could be due to Docker attempting to build the dependency from the code rather than using a prebuilt wheel binary. This happens with older versions of dependencies, and especially hard-to-build dependencies like scikit-learn.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Installing Scipy with Docker</title>
      <link>https://www.kylestratis.com/notes/installing-scipy-with-docker/</link>
      <pubDate>Tue, 04 Oct 2022 19:19:35 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/installing-scipy-with-docker/</guid>
      <description>&lt;p&gt;Certain packages can be troublesome to install in a Docker container when they&amp;rsquo;re defined in a &lt;code&gt;requirements.txt&lt;/code&gt; file, such as &lt;code&gt;scipy&lt;/code&gt;. If you&amp;rsquo;re running into issues installing these, which are typically problems with installing or building dependencies, try running &lt;code&gt;pip install&lt;/code&gt; from the Dockerfile itself, then installing from &lt;code&gt;requirements.txt&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h2 id=&#34;example&#34;&gt;Example&lt;/h2&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-dockerfile&#34; data-lang=&#34;dockerfile&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;RUN&lt;/span&gt; pip install --no-cache-dir --upgrade pip &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\ &lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;    pip install numpy scipy cython &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\ &lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;    pip install -r requirements.txt --target &lt;span style=&#34;color:#e6db74&#34;&gt;${&lt;/span&gt;FUNCTION_DIR&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    <item>
      <title>Including Assets from Parent Directories in Dockerized Lambda Functions with CDK</title>
      <link>https://www.kylestratis.com/notes/including-assets-from-parent-directories-in-dockerized-lambda-functions-with-cdk/</link>
      <pubDate>Tue, 04 Oct 2022 17:31:19 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/including-assets-from-parent-directories-in-dockerized-lambda-functions-with-cdk/</guid>
      <description>&lt;p&gt;If you have a Docker based Lambda that is defined in some directory and there are assets that the Lambda needs in the parent directory, &lt;code&gt;from_image_asset()&lt;/code&gt; takes &lt;code&gt;directory&lt;/code&gt; and &lt;code&gt;file&lt;/code&gt; parameters, so you can select the parent directory as well as the specific Dockerfile that describes the environment for the Lambda.&lt;/p&gt;&#xA;&lt;p&gt;Here is an example folder structure:&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;CDK_infrastructure/&#xA;    lambdas/&#xA;        lambda_one.py&#xA;        lambda_two.py&#xA;        lambda_pkg/&#xA;            ...&#xA;        docker_lambda/&#xA;            Dockerfile&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;And here is how you would set this up in your stack definition:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Addressing Docker No Space Left on Device Errors</title>
      <link>https://www.kylestratis.com/notes/addressing-docker-no-space-left-on-device-errors/</link>
      <pubDate>Mon, 15 Nov 2021 23:03:06 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/addressing-docker-no-space-left-on-device-errors/</guid>
      <description>&lt;p&gt;When you build Docker assets with CDK, they are still built locally and aren&amp;rsquo;t removed when the process is complete. You may eventually hit this error: &lt;code&gt;#8 29.62 ERROR: Could not install packages due to an OSError: [Errno 28] No space left on device&lt;/code&gt;. This is because the images and containers are sitting in the Docker disk image that is of a fixed size. To fix this, you can prune all stopped containers, images, and volumes with &lt;code&gt;docker system prune --all&lt;/code&gt;, volumes only &lt;code&gt;docker system prune --volumes&lt;/code&gt;. To prune all images: &lt;code&gt;docker prune images -af&lt;/code&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>To Build a Lambda from a Dockerfile in CDK</title>
      <link>https://www.kylestratis.com/notes/to-build-a-lambda-from-a-dockerfile-in-cdk/</link>
      <pubDate>Wed, 27 Oct 2021 19:24:41 +0000</pubDate>
      <guid>https://www.kylestratis.com/notes/to-build-a-lambda-from-a-dockerfile-in-cdk/</guid>
      <description>&lt;h2 id=&#34;creating-the-dockerfile&#34;&gt;Creating the Dockerfile&lt;/h2&gt;&#xA;&lt;p&gt;To set up a Dockerfile for a Lambda function that relies on non-AWS base images, you have to include the Python package &lt;code&gt;awslambdaric&lt;/code&gt; in your requirements and install it. Then, do the following in the Dockerfile:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-dockerfile&#34; data-lang=&#34;dockerfile&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;ENTRYPOINT&lt;/span&gt; [ &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;/usr/local/bin/python&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;-m&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;awslambdaric&amp;#34;&lt;/span&gt; ]  &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;CMD&lt;/span&gt; [&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;lambda_code.function_name&amp;#34;&lt;/span&gt;]&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;example&#34;&gt;Example&lt;/h3&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-dockerfile&#34; data-lang=&#34;dockerfile&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;ARG&lt;/span&gt; FUNCTION_DIR&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;/function&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;  &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;FROM&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; tensorflow/tensorflow:2.4.3 as DEV  &lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;ARG&lt;/span&gt; FUNCTION_DIR  &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;RUN&lt;/span&gt; mkdir -p &lt;span style=&#34;color:#e6db74&#34;&gt;${&lt;/span&gt;FUNCTION_DIR&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;## copies python code into container&amp;#39;s FUNCTION_DIR&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;COPY&lt;/span&gt; lambda_code.py &lt;span style=&#34;color:#e6db74&#34;&gt;${&lt;/span&gt;FUNCTION_DIR&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;## copies lambda_requirements.txt into container&amp;#39;s requirements.txt&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;COPY&lt;/span&gt; lambda_requirements.txt ./requirements.txt  &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;## copies dataset into container&amp;#39;s FUNCTION_DIR/dataset/&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;COPY&lt;/span&gt; dataset &lt;span style=&#34;color:#e6db74&#34;&gt;${&lt;/span&gt;FUNCTION_DIR&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt;/dataset/  &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;RUN&lt;/span&gt; pip install --no-cache-dir --upgrade pip &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\ &lt;/span&gt; &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;    pip install -r requirements.txt --target &lt;span style=&#34;color:#e6db74&#34;&gt;${&lt;/span&gt;FUNCTION_DIR&lt;span style=&#34;color:#e6db74&#34;&gt;}&lt;/span&gt;  &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;WORKDIR&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; ${FUNCTION_DIR}  &lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;ENTRYPOINT&lt;/span&gt; [ &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;python&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;-m&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;awslambdaric&amp;#34;&lt;/span&gt; ]  &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;CMD&lt;/span&gt; [&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;lambda_code.function_name&amp;#34;&lt;/span&gt;]&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;setting-up-the-lambda-in-cdk&#34;&gt;Setting Up the Lambda in CDK&lt;/h2&gt;&#xA;&lt;p&gt;To create a Lambda from a Dockerfile in CDK, use  &lt;code&gt;cdk.aws-lambda.DockerImageFunction&lt;/code&gt; when defining your Lambda:&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
