<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.8" -->
<?xml-stylesheet href="https://www.baszerr.eu/lib/exe/css.php?s=feed" type="text/css"?>
<rss version="2.0">
    <channel xmlns:g="http://base.google.com/ns/1.0">
        <title>BaSzErr - blog:2017:03:16</title>
        <description></description>
        <link>https://www.baszerr.eu/</link>
        <lastBuildDate>Wed, 06 May 2026 09:46:28 +0000</lastBuildDate>
        <generator>FeedCreator 1.8</generator>
        <image>
            <url>https://www.baszerr.eu/lib/exe/fetch.php?media=wiki:dokuwiki.svg</url>
            <title>BaSzErr</title>
            <link>https://www.baszerr.eu/</link>
        </image>
        <item>
            <title>2017-03-16_-_docker_cache_vs._docker_registry</title>
            <link>https://www.baszerr.eu/doku.php?id=blog:2017:03:16:2017-03-16_-_docker_cache_vs._docker_registry</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;docker_cache_vs_docker_registry&quot;&gt;2017-03-16 - docker cache vs. docker registry&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
&lt;a href=&quot;https://www.baszerr.eu/lib/exe/detail.php?id=blog%3A2017%3A03%3A16%3A2017-03-16_-_docker_cache_vs._docker_registry&amp;amp;media=blog:2017:03:16:docker_logo.png&quot; class=&quot;media&quot; title=&quot;blog:2017:03:16:docker_logo.png&quot;&gt;&lt;img src=&quot;https://www.baszerr.eu/lib/exe/fetch.php?media=blog:2017:03:16:docker_logo.png&quot; class=&quot;mediaright&quot; align=&quot;right&quot; loading=&quot;lazy&quot; title=&quot;docker logo&quot; alt=&quot;docker logo&quot; /&gt;&lt;/a&gt;
i&amp;#039;ve spent most of the last working day exploring issue on our &lt;a href=&quot;https://en.wikipedia.org/wiki/continuous integration&quot; class=&quot;interwiki iw_wp&quot; title=&quot;https://en.wikipedia.org/wiki/continuous integration&quot;&gt;CI&lt;/a&gt; servers. here is the story…
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;2017-03-16 - docker cache vs. docker registry&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;docker_cache_vs_docker_registry&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:1,&amp;quot;range&amp;quot;:&amp;quot;1-238&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit2&quot; id=&quot;disease_s_history&quot;&gt;disease&amp;#039;s history&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
after adding jobs to rebuild &lt;a href=&quot;https://docker.com/&quot; class=&quot;urlextern&quot; title=&quot;https://docker.com/&quot; rel=&quot;ugc nofollow&quot;&gt;docker&lt;/a&gt; images with each revision, i&amp;#039;ve added an internal &lt;a href=&quot;https://docs.docker.com/registry/&quot; class=&quot;urlextern&quot; title=&quot;https://docs.docker.com/registry/&quot; rel=&quot;ugc nofollow&quot;&gt;docker registry&lt;/a&gt;, to make sure we have a common place to store generated images (easy, convenient, reproducible, no need to build anything manually, etc…). since we have multiple agents, i&amp;#039;ve quickly noticed that even though i explicitly do &lt;em&gt;docker pull&lt;/em&gt; on images, they still get rebuild over and over again, even though &lt;em&gt;Dockerfile&lt;/em&gt; (nor its dependencies) did not changed.
&lt;/p&gt;

&lt;p&gt;
time went by (images too some time to build) and there was not apparent reason why caching does not work. starting docker daemon with debug logs enabled indicated that cache is not used (“thank you captain obvious”). so what&amp;#039;s going on?
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;disease&amp;#039;s history&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;disease_s_history&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:2,&amp;quot;range&amp;quot;:&amp;quot;239-1037&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit3&quot; id=&quot;world_is_a_changing_place&quot;&gt;world is a changing place&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
querying the internet revealed an interesting fact – &lt;a href=&quot;https://github.com/docker/docker/issues/20316&quot; class=&quot;urlextern&quot; title=&quot;https://github.com/docker/docker/issues/20316&quot; rel=&quot;ugc nofollow&quot;&gt;in docker 1.10.0 caching has drastically changed&lt;/a&gt;. &lt;abbr title=&quot;Too long; didn&amp;#039;t read&quot;&gt;TL;DR&lt;/abbr&gt;. the problem is that, if you allow remote images to add stuff to your local cache (as docker used to do, until some time ago), it will effectively allow anyone to misguide your cache, leading to potential security breach. example provided was sth along this:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;FROM debian
RUN apt-get update&lt;/pre&gt;

&lt;p&gt;
let&amp;#039;s say that this will generate cache entries #1 (“FROM”) and #2 (“RUN”). now malicious image could pollute your cache, putting anything behind “RUN”, and just pretending this was achieved with a declared “RUN” command. fix is simple – do not trust remote cache.
&lt;/p&gt;

&lt;p&gt;
there is however a problem. you no longer can rely on the fact that builds on different machines will generate the same images. in fact it&amp;#039;s directly opposite – it will always generate new image! this means, that now each build host must (sooner or later) rebuild image to populate own cache. it also means that pushing to docker registry will take N-times as much space (where N i number of build machines)! so you loose both in terms of time and size.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;world is a changing place&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;world_is_a_changing_place&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:3,&amp;quot;range&amp;quot;:&amp;quot;1038-2256&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit4&quot; id=&quot;what_can_be_done&quot;&gt;what can be done?&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
there are different ways to overcome this issue. one idea is to &lt;a href=&quot;http://blog.runnable.com/post/145362675491/distributing-docker-cache-across-hosts&quot; class=&quot;urlextern&quot; title=&quot;http://blog.runnable.com/post/145362675491/distributing-docker-cache-across-hosts&quot; rel=&quot;ugc nofollow&quot;&gt;share caches between different machines&lt;/a&gt; and/or propagate caches via &lt;em&gt;docker save&lt;/em&gt; + &lt;em&gt;docker load&lt;/em&gt; (still shared storage is needed). it however requires another infrastructure element and extra complexity.
&lt;/p&gt;

&lt;p&gt;
another workaround is to explicitly allow caching entries, from a given source, with &lt;a href=&quot;https://github.com/docker/docker/pull/26839&quot; class=&quot;urlextern&quot; title=&quot;https://github.com/docker/docker/pull/26839&quot; rel=&quot;ugc nofollow&quot;&gt;--cache-from &amp;quot;image:tag&amp;quot;&lt;/a&gt; entry. it has entered docker 1.13. this looks the most promising at the moment.
&lt;/p&gt;

&lt;p&gt;
one more alternative i was thinking about was to use cache info on what has already been built locally and store it for extended periods of time. this way it would be enough to keep one hash per layer locally. even though each host still need to rebuild the image at least once, it does not need to keep it forever, just to have caches populated. instead it could push it to (local) instance of docker registry and remove locally. next time it is needed, it&amp;#039;s enough to pull it back from registry and re-validate hashes of layers and content match expected ones.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;what can be done?&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;what_can_be_done&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:4,&amp;quot;range&amp;quot;:&amp;quot;2257-&amp;quot;} --&gt;</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Tue, 15 Jun 2021 20:09:46 +0000</pubDate>
        </item>
        <item>
            <title>2017-03-16_-_starting_a_script</title>
            <link>https://www.baszerr.eu/doku.php?id=blog:2017:03:16:2017-03-16_-_starting_a_script</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;starting_a_script&quot;&gt;2017-03-16 - starting a script&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
some time ago we had an issue on &lt;a href=&quot;https://en.wikipedia.org/wiki/continuous integration&quot; class=&quot;interwiki iw_wp&quot; title=&quot;https://en.wikipedia.org/wiki/continuous integration&quot;&gt;CI&lt;/a&gt; build machines. on test environment, failed builds did not fail. all CI did was to run a simple bash script – sth along these lines:
&lt;/p&gt;
&lt;pre class=&quot;code bash&quot;&gt;&lt;span class=&quot;co0&quot;&gt;#!/bin/bash -ex&lt;/span&gt;
&lt;span class=&quot;kw3&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;build&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;path
cmake &lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;source&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;dir&lt;/span&gt;
ninja
ctest&lt;/pre&gt;

&lt;p&gt;
we double-checked that build errors failed the script locally, but not on our CI. after a bit of digging it turned out that CI is running scripts like this:
&lt;/p&gt;
&lt;pre class=&quot;code bash&quot;&gt;&lt;span class=&quot;kw2&quot;&gt;bash&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;path&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;to&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;ci&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;script&lt;/pre&gt;

&lt;p&gt;
while we run these “the usual way”:
&lt;/p&gt;
&lt;pre class=&quot;code bash&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;path&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;to&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;ci
.&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;script&lt;/pre&gt;

&lt;p&gt;
difference? when source-running, bash-bang is ignored! :) this in turn means that stopping on error was not honored – the rest you already know.
&lt;/p&gt;

&lt;p&gt;
answer? update your script:
&lt;/p&gt;
&lt;pre class=&quot;code bash&quot;&gt;&lt;span class=&quot;co0&quot;&gt;#!/bin/bash&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;-ex&lt;/span&gt;       &lt;span class=&quot;co0&quot;&gt;# NOTE: changing shell settings inside the script, not bash-bang&lt;/span&gt;
&lt;span class=&quot;kw3&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;build&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;path
cmake &lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;source&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;dir&lt;/span&gt;
ninja
ctest&lt;/pre&gt;

&lt;/div&gt;
</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Tue, 15 Jun 2021 20:09:46 +0000</pubDate>
        </item>
        <item>
            <title>2017-03-16_-_starting_container_as_non-root</title>
            <link>https://www.baszerr.eu/doku.php?id=blog:2017:03:16:2017-03-16_-_starting_container_as_non-root</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;starting_container_as_non-root&quot;&gt;2017-03-16 - starting container as non-root&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
&lt;a href=&quot;https://www.baszerr.eu/lib/exe/detail.php?id=blog%3A2017%3A03%3A16%3A2017-03-16_-_starting_container_as_non-root&amp;amp;media=blog:2017:03:16:docker_logo.png&quot; class=&quot;media&quot; title=&quot;blog:2017:03:16:docker_logo.png&quot;&gt;&lt;img src=&quot;https://www.baszerr.eu/lib/exe/fetch.php?media=blog:2017:03:16:docker_logo.png&quot; class=&quot;mediaright&quot; align=&quot;right&quot; loading=&quot;lazy&quot; title=&quot;docker logo&quot; alt=&quot;docker logo&quot; /&gt;&lt;/a&gt;
around the end of last year i spent some time investigating how to run a script, that runs some command in &lt;a href=&quot;https://en.wikipedia.org/wiki/docker (software)&quot; class=&quot;interwiki iw_wp&quot; title=&quot;https://en.wikipedia.org/wiki/docker (software)&quot;&gt;docker&lt;/a&gt; container, with a user/group of a local user, that has started the script. this was important to me, so that files that docker container create on a mounted volume are not owned by root:root, but me:me instead (i.e. user that started the container). the problem is, that different users have different UIDs/GIDs, on different machines. how to unify this?
&lt;/p&gt;

&lt;p&gt;
there is a &lt;em&gt;-u&lt;/em&gt; switch do &lt;em&gt;docker run&lt;/em&gt;, that allows to pass in user and a group. it looked very promising at first:
&lt;/p&gt;
&lt;pre class=&quot;code bash&quot;&gt;docker run &lt;span class=&quot;re5&quot;&gt;-it&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;--rm&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;-u&lt;/span&gt; oops debian:testing&lt;/pre&gt;

&lt;p&gt;
…but it failed:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;docker: Error response from daemon: linux spec user: unable to find user oops: no matching entries in passwd file.&lt;/pre&gt;

&lt;p&gt;
user must exist in the image, in order to start this way. i&amp;#039;ve played around a lot with different options, helper proxy scripts, parameters/UIDs deduction, etc… finally it turned out there is a super simple, but not widely known solution: &lt;em&gt;-u&lt;/em&gt; switch also accepts UIDs and GIDs, and then they do not need to map to any user inside the container!
&lt;/p&gt;
&lt;pre class=&quot;code bash&quot;&gt;docker run &lt;span class=&quot;re5&quot;&gt;-it&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;--rm&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;-u&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;666&lt;/span&gt;:&lt;span class=&quot;nu0&quot;&gt;999&lt;/span&gt; debian:testing&lt;/pre&gt;
&lt;pre class=&quot;code&quot;&gt;I have no name!@07bf48e8b622:/$ id
uid=666 gid=999 groups=999&lt;/pre&gt;

&lt;p&gt;
from here on it was simple. for the sake of example let&amp;#039;s assume we want to mount users &lt;em&gt;~/data&lt;/em&gt; directory, to &lt;em&gt;/mount&lt;/em&gt; directory in the container, while making sure that files generated by a container map to user who runs the command. the spell is:
&lt;/p&gt;
&lt;pre class=&quot;code bash&quot;&gt;docker run &lt;span class=&quot;re5&quot;&gt;-it&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;--rm&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;-u&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;&lt;span class=&quot;es4&quot;&gt;$(id -u)&lt;/span&gt;:&lt;span class=&quot;es4&quot;&gt;$(id -g)&lt;/span&gt;&amp;quot;&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;-v&lt;/span&gt; ~&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;data:&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;mnt my_image some_cmd&lt;/pre&gt;

&lt;p&gt;
hope this will save you some time. enjoy! :)
&lt;/p&gt;

&lt;/div&gt;
</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Tue, 15 Jun 2021 20:09:46 +0000</pubDate>
        </item>
    </channel>
</rss>
