<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Docker &#8211; Manuel Bogner&#039;s Blog</title>
	<atom:link href="https://blog.mbo.dev/archives/category/docker/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.mbo.dev</link>
	<description>Solutions to everyday IT problems</description>
	<lastBuildDate>Thu, 30 Nov 2023 00:46:32 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://blog.mbo.dev/wp-content/uploads/2022/11/cropped-cropped-mbo-white_opt-32x32.png</url>
	<title>Docker &#8211; Manuel Bogner&#039;s Blog</title>
	<link>https://blog.mbo.dev</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>get shell for docker vm on mac</title>
		<link>https://blog.mbo.dev/archives/1993</link>
		
		<dc:creator><![CDATA[Manuel Bogner]]></dc:creator>
		<pubDate>Thu, 30 Nov 2023 00:46:30 +0000</pubDate>
				<category><![CDATA[Docker]]></category>
		<guid isPermaLink="false">https://blog.coffeebeans.at/?p=1993</guid>

					<description><![CDATA[For setting values on the docker vm on your mac you need to get a shell. Elastic has some statements online that don&#8217;t work on latest MacOS (14.1.1 + docker desktop 24.0.6). To get a shell you can use this command:]]></description>
										<content:encoded><![CDATA[
<p>For setting values on the docker vm on your mac you need to get a shell. Elastic has some statements online that don&#8217;t work on latest MacOS (14.1.1 + docker desktop 24.0.6). To get a shell you can use this command:</p>



<pre class="wp-block-code"><code>docker run -it --privileged --pid=host debian nsenter -t 1 -m -u -n -i sh</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Inspect docker container image without starting it</title>
		<link>https://blog.mbo.dev/archives/1990</link>
		
		<dc:creator><![CDATA[Manuel Bogner]]></dc:creator>
		<pubDate>Sun, 19 Nov 2023 12:53:23 +0000</pubDate>
				<category><![CDATA[Docker]]></category>
		<guid isPermaLink="false">https://blog.coffeebeans.at/?p=1990</guid>

					<description><![CDATA[These two commands result in a file containing a list of all files included in the container image. You can also export the complete container into a tar file:]]></description>
										<content:encoded><![CDATA[
<pre class="wp-block-code"><code>docker create --name suspect-container suspect-image:version
docker export suspect-container | tar t > suspect-container-files.txt</code></pre>



<p>These two commands result in a file containing a list of all files included in the container image.</p>



<p>You can also export the complete container into a tar file:</p>



<pre class="wp-block-code"><code>docker export suspect-container > test.tar </code></pre>



<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>keycloak in docker compose with healthcheck</title>
		<link>https://blog.mbo.dev/archives/1986</link>
		
		<dc:creator><![CDATA[Manuel Bogner]]></dc:creator>
		<pubDate>Mon, 13 Nov 2023 00:09:14 +0000</pubDate>
				<category><![CDATA[Docker]]></category>
		<guid isPermaLink="false">https://blog.coffeebeans.at/?p=1986</guid>

					<description><![CDATA[Docker images from quay.io/keycloak/keycloak don&#8217;t contain any commands for a usual healthcheck and installing software is also not trivial. In a discussion on https://github.com/keycloak/keycloak/issues/17273 I found a solution that checks /proc/net/tcp for an open port 8080. That file contains all open ports in hex format. cat and grep are included in the image. So a [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>Docker images from <em>quay.io/keycloak/keycloak</em> don&#8217;t contain any commands for a usual healthcheck and installing software is also not trivial. In a discussion on https://github.com/keycloak/keycloak/issues/17273 I found a solution that checks <code>/proc/net/tcp</code> for an open port 8080. That file contains all open ports in hex format. <code>cat</code> and <code>grep</code> are included in the image. So a healthcheck can be realised without installing any additional software.</p>



<p>As running the container isn&#8217;t that trivial and documentation is a bit hard to find &#8211; here my full docker compose config with the healthcheck:</p>



<pre class="wp-block-code"><code>  keycloak:
    image: quay.io/keycloak/keycloak:latest
    hostname: keycloak
    container_name: keycloak
    command:
      - start-dev
    environment:
      KEYCLOAK_ADMIN: admin
      KEYCLOAK_ADMIN_PASSWORD: s3cr3t
    ports:
      - "127.0.0.1:8080:8080"
    healthcheck:
      test: cat /proc/net/tcp | grep '00000000:1F90 00000000:0000' || exit 1
      interval: 5s
      timeout: 2s
      retries: 20
      start_period: 10s</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>docker pull proxyconnect tcp: dial tcp: lookup http.docker.internal on 192.168.65&#8230; timeout</title>
		<link>https://blog.mbo.dev/archives/1982</link>
		
		<dc:creator><![CDATA[Manuel Bogner]]></dc:creator>
		<pubDate>Mon, 06 Nov 2023 08:21:23 +0000</pubDate>
				<category><![CDATA[Docker]]></category>
		<category><![CDATA[Mac]]></category>
		<guid isPermaLink="false">https://blog.coffeebeans.at/?p=1982</guid>

					<description><![CDATA[After upgrading to macOS 14.1 my docker installation stopped woring and when I tried to pull an image it answered with the following error message: 192.168.65.0/24 is the configured docker internal network of Docker Desktop. It was running on defaults and I wasn&#8217;t aware of any manual changes. DNS of my host system worked properly: [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>After upgrading to macOS 14.1 my docker installation stopped woring and when I tried to pull an image it answered with the following error message:</p>



<pre class="wp-block-code"><code>➜  ~ docker pull ubuntu                                                                                                                        
Using default tag: latest                                                                                                                      
Error response from daemon: Get "https://registry-1.docker.io/v2/": proxyconnect tcp: dial tcp: lookup http.docker.internal on 192.168.65.7:53:
 read udp 192.168.65.6:62314-&gt;192.168.65.7:53: i/o timeout        </code></pre>



<p>192.168.65.0/24 is the configured docker internal network of Docker Desktop. It was running on defaults and I wasn&#8217;t aware of any manual changes. DNS of my host system worked properly:</p>



<pre class="wp-block-code"><code>➜  ~ host registry-1.docker.io                                                                                                                 
registry-1.docker.io has address 34.194.164.123                                                                                                
registry-1.docker.io has address 18.215.138.58                                                                                                 
registry-1.docker.io has address 52.1.184.176                                                                                                  
registry-1.docker.io has IPv6 address 2600:1f18:2148:bc00:8334:ca86:c3d6:a507                                                                  
registry-1.docker.io has IPv6 address 2600:1f18:2148:bc02:cfd8:db68:ea1f:277c                                                                  
registry-1.docker.io has IPv6 address 2600:1f18:2148:bc01:a3b0:6734:c617:7c5c </code></pre>



<p>What exactly caused the issue didn&#8217;t reveal but resetting Docker Desktop to factory defaults fixed the problem. You can find this on the top right corner of the window behind the small bug icon -&gt; &#8220;Reset to factory defaults&#8221; button.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Start PostgreSQL correctly with docker-compose.yml</title>
		<link>https://blog.mbo.dev/archives/1967</link>
		
		<dc:creator><![CDATA[Manuel Bogner]]></dc:creator>
		<pubDate>Thu, 24 Aug 2023 20:56:44 +0000</pubDate>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Docker]]></category>
		<guid isPermaLink="false">https://blog.coffeebeans.at/?p=1967</guid>

					<description><![CDATA[I&#8217;m using PostgreSQL in a lot of projects and in my dev environments I always run it with docker-compose. But configuring it properly isn&#8217;t so clear if you want to use proper time zone and a health check. Attached the config with a custom database name &#8220;db&#8221; and an admin user. With this pg_isready is [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>I&#8217;m using PostgreSQL in a lot of projects and in my dev environments I always run it with docker-compose. But configuring it properly isn&#8217;t so clear if you want to use proper time zone and a health check. Attached the config with a custom database name &#8220;db&#8221; and an admin user. With this <code>pg_isready</code> is used in the healthcheck section with proper parameters based on the config. Works perfect for me like this. If you have improvements, please let me know.</p>



<pre class="wp-block-code"><code>version: "3.9"
services:

  postgres:
    image: postgres:15-alpine
    container_name: postgres
    hostname: postgres
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - postgres:/var/lib/postgresql/data/pgdata:rw
    ports:
      - "127.0.0.1:5432:5432"
    environment:
      POSTGRES_DB: db
      POSTGRES_USER: admin
      POSTGRES_PASSWORD: admin
      PGDATA: /var/lib/postgresql/data/pgdata
      TZ: UTC
      PGTZ: UTC
    healthcheck:
      test: &#91; "CMD-SHELL", "pg_isready -U admin -d db" ]
      interval: 1s
      timeout: 5s
      retries: 10

volumes:
  postgres:</code></pre>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to create docker containers for multiple platforms / architectures</title>
		<link>https://blog.mbo.dev/archives/1930</link>
		
		<dc:creator><![CDATA[Manuel Bogner]]></dc:creator>
		<pubDate>Mon, 17 Apr 2023 11:07:56 +0000</pubDate>
				<category><![CDATA[Docker]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac]]></category>
		<guid isPermaLink="false">https://blog.coffeebeans.at/?p=1930</guid>

					<description><![CDATA[First you need to choose a base image that is available for the target platforms as well. Create your Dockerfile as usual and then build the container for different platforms. This example would create an amd64 and a aarch64 (arm64/v8) image: Based on these you can create a manifest and upload it: This would already [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>First you need to choose a base image that is available for the target platforms as well. Create your Dockerfile as usual and then build the container for different platforms.</p>



<p>This example would create an <em><strong>amd64</strong></em> and a <em><strong>aarch64</strong></em> (arm64/v8) image:</p>



<pre class="wp-block-code"><code># ARM
<strong>docker build </strong>--platform=linux/<strong>aarch64</strong> -t <em>&lt;dockerhub-username>/&lt;image-name>:&lt;version></em><strong>-aarch64</strong> .
<strong>docker push</strong> -t <em>&lt;dockerhub-username>/&lt;image-name>:&lt;version></em><strong>-aarch64</strong>

# AMD
<strong>docker build</strong> --platform=linux/<strong>amd64</strong> -t <em>&lt;dockerhub-username>/&lt;image-name>:&lt;version></em>-<strong>amd64</strong> .
<strong>docker push</strong> -t <em>&lt;dockerhub-username>/&lt;image-name>:&lt;version></em><strong>-amd64</strong></code></pre>



<p>Based on these you can create a manifest and upload it:</p>



<pre class="wp-block-code"><code><strong>docker manifest create</strong> <em>&lt;dockerhub-username>/&lt;image-name>:&lt;version></em> \
  --amend <em>&lt;dockerhub-username>/&lt;image-name>:&lt;version></em><strong>-aarch64</strong> \
  --amend <em>&lt;dockerhub-username>/&lt;image-name>:&lt;version></em><strong>-amd64</strong>
<strong>docker manifest push</strong> <em>&lt;dockerhub-username>/&lt;image-name>:&lt;version></em></code></pre>



<p>This would already provide an image <em>&lt;dockerhub-username>/&lt;image-name>:&lt;version></em> available for <em>amd64</em> and <em>aarch64</em> platform on docker hub. But for convenience we also want a <em>latest</em> tag for that manifest:</p>



<pre class="wp-block-code"><code><strong>docker manifest create</strong> <em>&lt;dockerhub-username>/&lt;image-name></em>:<strong>latest</strong> \
  --<strong>amend</strong> <em>&lt;dockerhub-username>/&lt;image-name>:&lt;version></em><strong>-aarch64</strong> \
  --<strong>amend</strong> <em>&lt;dockerhub-username>/&lt;image-name>:&lt;version></em><strong>-amd64</strong>
<strong>docker manifest push</strong> <em>&lt;dockerhub-username>/&lt;image-name></em><strong>:latest</strong></code></pre>



<p>This uses the same hashes as the version uploaded before.</p>



<p>I am not sure if this is the correct or best way, but at least it works. On my M1 mac buildx didn&#8217;t work so I fell back to manifests that aren&#8217;t that complicated anyway.</p>



<p>Here an example image that was created and uploaded like this: <a rel="noreferrer noopener" href="https://registry.hub.docker.com/r/mbopm/cyberchef" target="_blank">https://registry.hub.docker.com/r/mbopm/cyberchef</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Replace docker with podman on MacOS</title>
		<link>https://blog.mbo.dev/archives/1891</link>
		
		<dc:creator><![CDATA[Manuel Bogner]]></dc:creator>
		<pubDate>Sat, 03 Dec 2022 12:20:31 +0000</pubDate>
				<category><![CDATA[Docker]]></category>
		<category><![CDATA[Mac]]></category>
		<guid isPermaLink="false">https://blog.coffeebeans.at/?p=1891</guid>

					<description><![CDATA[Docker wants to bill companies for Docker Desktop. In my opinion it&#8217;s not worth it because there are multiple options how to replace it without the need to really change habits. Here the statement taken from Docker FAQ regarding payment for Docker Desktop: Who’s required to pay for Docker Desktop? Docker Desktop requires a paid, [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>Docker wants to bill companies for Docker Desktop. In my opinion it&#8217;s not worth it because there are multiple options how to replace it without the need to really change habits. Here the statement taken from Docker FAQ regarding payment for Docker Desktop:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<h5 class="wp-block-heading">Who’s required to pay for Docker Desktop?</h5>



<p>Docker Desktop requires a paid, per-user subscription for organizations with more than 250 employees or more than $10 million in annual revenue per our&nbsp;<a href="https://www.docker.com/legal/docker-terms-service/">terms of service</a>.</p>
<cite>https://www.docker.com/pricing/faq/, 2022-12-03</cite></blockquote>



<p>Podman is an open source and free replacement licensed under Apache-2.0. Here the description of it taken from the homepage:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p><a class="reference external" style="color: rgb(0, 75, 107); border-bottom: 1px dotted rgb(0, 75, 107); font-family: Georgia, serif; font-size: 17px; white-space: normal;" href="http://podman.io/">Podman</a><span style="color: rgb(62, 67, 73); font-family: Georgia, serif; font-size: 17px; white-space: normal;">&nbsp;is a daemonless, open source, Linux native tool designed to make it easy to find, run, build, share and deploy applications using Open Containers Initiative (</span><a class="reference external" style="color: rgb(0, 75, 107); border-bottom: 1px dotted rgb(0, 75, 107); font-family: Georgia, serif; font-size: 17px; white-space: normal;" href="https://www.opencontainers.org/">OCI</a><span style="color: rgb(62, 67, 73); font-family: Georgia, serif; font-size: 17px; white-space: normal;">)&nbsp;</span><a class="reference external" style="color: rgb(0, 75, 107); border-bottom: 1px dotted rgb(0, 75, 107); font-family: Georgia, serif; font-size: 17px; white-space: normal;" href="https://developers.redhat.com/blog/2018/02/22/container-terminology-practical-introduction/#h.j2uq93kgxe0e">Containers</a><span style="color: rgb(62, 67, 73); font-family: Georgia, serif; font-size: 17px; white-space: normal;">&nbsp;and&nbsp;</span><a class="reference external" style="color: rgb(0, 75, 107); border-bottom: 1px dotted rgb(0, 75, 107); font-family: Georgia, serif; font-size: 17px; white-space: normal;" href="https://developers.redhat.com/blog/2018/02/22/container-terminology-practical-introduction/#h.dqlu6589ootw">Container Images</a><span style="color: rgb(62, 67, 73); font-family: Georgia, serif; font-size: 17px; white-space: normal;">. Podman provides a command line interface (CLI) familiar to anyone who has used the Docker&nbsp;</span><a class="reference external" style="color: rgb(0, 75, 107); border-bottom: 1px dotted rgb(0, 75, 107); font-family: Georgia, serif; font-size: 17px; white-space: normal;" href="https://developers.redhat.com/blog/2018/02/22/container-terminology-practical-introduction/#h.6yt1ex5wfo3l">Container Engine</a><span style="color: rgb(62, 67, 73); font-family: Georgia, serif; font-size: 17px; white-space: normal;">. Most users can simply alias Docker to Podman (</span><cite style="color: rgb(62, 67, 73); font-family: Georgia, serif; font-size: 17px; white-space: normal;">alias docker=podman</cite><span style="color: rgb(62, 67, 73); font-family: Georgia, serif; font-size: 17px; white-space: normal;">) without any problems. Similar to other common&nbsp;</span><a class="reference external" style="color: rgb(0, 75, 107); border-bottom: 1px dotted rgb(0, 75, 107); font-family: Georgia, serif; font-size: 17px; white-space: normal;" href="https://developers.redhat.com/blog/2018/02/22/container-terminology-practical-introduction/#h.6yt1ex5wfo3l">Container Engines</a><span style="color: rgb(62, 67, 73); font-family: Georgia, serif; font-size: 17px; white-space: normal;">&nbsp;(Docker, CRI-O, containerd), Podman relies on an OCI compliant&nbsp;</span><a class="reference external" style="color: rgb(0, 75, 107); border-bottom: 1px dotted rgb(0, 75, 107); font-family: Georgia, serif; font-size: 17px; white-space: normal;" href="https://developers.redhat.com/blog/2018/02/22/container-terminology-practical-introduction/#h.6yt1ex5wfo55">Container Runtime</a><span style="color: rgb(62, 67, 73); font-family: Georgia, serif; font-size: 17px; white-space: normal;">&nbsp;(runc, crun, runv, etc) to interface with the operating system and create the running containers. This makes the running containers created by Podman nearly indistinguishable from those created by any other common container engine.</span></p>
<cite>https://docs.podman.io/en/latest/, 2022-12-03</cite></blockquote>



<p></p>



<p>To install it I simply followed these steps on my Mac:</p>



<pre class="wp-block-code"><code>brew install podman
podman machine init # create a qemu virtual machine
podman machine start # start it
export DOCKER_HOST='unix:///Users/manuel/.local/share/containers/podman/machine/podman-machine-default/podman.sock'</code></pre>



<p></p>



<p>With this in place you can continue running <code>docker</code> commands as usual and for most users a simple alias will do the trick if you don&#8217;t want to write podman instead of docker.</p>



<p>In IntelliJ you need to configure the <code>TCP socket</code> instead of <code>Docker for Mac</code> in the settings. Then also IntelliJ continues talking to the podman instance as it were a Docker Desktop. I named my host &#8220;Podman&#8221; instead of &#8220;Docker&#8221; and right-clicking the compose file and selecting &#8220;Run on Podman&#8221; worked like a charm. No difference to Docker Desktop before.</p>



<p>When you don&#8217;t need docker / podman you can stop it by running</p>



<pre class="wp-block-code"><code>podman machine stop</code></pre>



<p></p>



<p>To restart it simply write &#8220;start&#8221; instead of stop.</p>



<p>Here is what I added to my <code>.zshrc</code> file:</p>



<pre class="wp-block-code"><code>alias docker='podman'
export DOCKER_HOST='unix:///Users/manuel/.local/share/containers/podman/machine/podman-machine-default/podman.sock'</code></pre>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
