<?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 | Nerdpress.org</title>
	<atom:link href="https://nerdpress.org/category/project-setup/docker-project-setup/feed/" rel="self" type="application/rss+xml" />
	<link>https://nerdpress.org</link>
	<description>...dev, tech problems and solutions.</description>
	<lastBuildDate>Thu, 19 May 2022 07:55:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Docker-compose and Unknown MySQL server host</title>
		<link>https://nerdpress.org/2020/12/08/docker-compose-and-unknown-mysql-server-host/</link>
		
		<dc:creator><![CDATA[Ivo Bathke]]></dc:creator>
		<pubDate>Tue, 08 Dec 2020 10:06:25 +0000</pubDate>
				<category><![CDATA[docker]]></category>
		<category><![CDATA[docker-compose]]></category>
		<category><![CDATA[MySQL]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2962</guid>

					<description><![CDATA[<p>In case you encounter this error with mysql and your docker-compose setup: &#8230; and you dont know why because everything seems to be correct. Then you might have an upgrade problem with mysql because you are reusing an old volume that was created for another mysql version.This can happen when you use a unspecified tag &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2020/12/08/docker-compose-and-unknown-mysql-server-host/" class="more-link">Continue reading<span class="screen-reader-text"> "Docker-compose and Unknown MySQL server host"</span></a></p>
The post <a href="https://nerdpress.org/2020/12/08/docker-compose-and-unknown-mysql-server-host/">Docker-compose and Unknown MySQL server host</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>In case you encounter this error with mysql and your docker-compose setup:</p>


<pre class="wp-block-code"><span><code class="hljs language-xml">Unknown MySQL server host <span class="hljs-tag">&lt;<span class="hljs-name">mysql-service-name</span>&gt;</span></code></span></pre>


<p>&#8230; and you dont know why because everything seems to be correct.</p>



<p>Then you might have an upgrade problem with mysql because you are reusing an old volume that was created for another mysql version.<br>This can happen when you use a unspecified tag as <code>mysql:latest</code> (not recommended anyway) and there was a version bump in the official mysql image. <br>Or you upgraded the mysql container yourself, f.e. from <code>mysql:5.6</code> to <code>mysql:5.7</code> and you are reusing the data volume with the mysql files.</p>



<span id="more-2962"></span>



<p>When you check the startup logs you might see that mysql container is shutting down after startup because of an error like this:</p>


<pre class="wp-block-code"><span><code class="hljs">Can't open the mysql.plugin table. Please run mysql_upgrade to create it.</code></span></pre>


<p>You can run the upgrade command in the container:</p>


<pre class="wp-block-code"><span><code class="hljs language-javascript">docker exec -it mysql_container_name bash -c <span class="hljs-string">"mysql_upgrade -uroot -proot"</span></code></span></pre>


<p>Or simply delete the volume and recreate it.<br><em>Note: the data will unfortunatly be lost. So better dump the data before deleting the volume and reimport it.</em><br>In my case its no problem because im starting a new project anyway.</p>



<p>To delete the volume you can:</p>


<pre class="wp-block-code"><span><code class="hljs language-xml">docker volume rm <span class="hljs-tag">&lt;<span class="hljs-name">volume</span> <span class="hljs-attr">id</span>&gt;</span></code></span></pre>


<p>Or just delete the data dir:</p>


<pre class="wp-block-code"><span><code class="hljs">rm -rf ./data/mysql</code></span></pre>


<p>Then restart your setup so the mysql container recreates the databases:</p>


<pre class="wp-block-code"><span><code class="hljs">docker-compose up</code></span></pre>


<p>and mysql is working again and the application is able to connect. :)</p>The post <a href="https://nerdpress.org/2020/12/08/docker-compose-and-unknown-mysql-server-host/">Docker-compose and Unknown MySQL server host</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>docker-compose network not found</title>
		<link>https://nerdpress.org/2020/01/27/docker-compose-network-not-found/</link>
		
		<dc:creator><![CDATA[Ivo Bathke]]></dc:creator>
		<pubDate>Mon, 27 Jan 2020 10:22:17 +0000</pubDate>
				<category><![CDATA[docker]]></category>
		<category><![CDATA[docker-compose]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2903</guid>

					<description><![CDATA[<p>Recently i more often encounter this strange error in my docker-compose setups while bringing up the containers with docker-compose up: ERROR: for docker_myproject_phpmyadmin_1 Cannot start service mg_myproject_phpmyadmin: network 15dff95a23808fe9d14b3dae71c0daeaa8b274c90566baa5beff37f3738033b6 not found For some reason the networks were deleted and docker-compose doesnt automatically recreate networks unless you tell so by forcing docker to recreate containers: docker-compose &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2020/01/27/docker-compose-network-not-found/" class="more-link">Continue reading<span class="screen-reader-text"> "docker-compose network not found"</span></a></p>
The post <a href="https://nerdpress.org/2020/01/27/docker-compose-network-not-found/">docker-compose network not found</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>Recently i more often encounter this strange error in my docker-compose setups while bringing up the containers with <code>docker-compose up</code>:</p>



<p><code>ERROR: for docker_myproject_phpmyadmin_1  Cannot start service mg_myproject_phpmyadmin: network 15dff95a23808fe9d14b3dae71c0daeaa8b274c90566baa5beff37f3738033b6 not found</code></p>



<span id="more-2903"></span>



<p>For some reason the networks were deleted and docker-compose doesnt automatically recreate networks unless you tell so by forcing docker to recreate containers:</p>



<p><code>docker-compose up --force-recreate</code></p>



<p>Solution came from this issue:<br /> <a href="https://github.com/docker/compose/issues/5745#issuecomment-370031631">https://github.com/docker/compose/issues/5745#issuecomment-370031631</a></p>



<p>Probably i have to explicitly declare the networks to prevent mixups between projects.<br />Though i thought this would not be necessary&#8230;</p>The post <a href="https://nerdpress.org/2020/01/27/docker-compose-network-not-found/">docker-compose network not found</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Adminer for Sqlite in Docker</title>
		<link>https://nerdpress.org/2019/10/23/adminer-for-sqlite-in-docker/</link>
		
		<dc:creator><![CDATA[Ivo Bathke]]></dc:creator>
		<pubDate>Wed, 23 Oct 2019 08:02:47 +0000</pubDate>
				<category><![CDATA[docker]]></category>
		<category><![CDATA[Sqlite]]></category>
		<category><![CDATA[adminer]]></category>
		<category><![CDATA[docker-compose]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2889</guid>

					<description><![CDATA[<p>Recently i wanted to use Sqlite with Adminer in Docker and it turned out to be not so easy. I actually thought i could just declare Adminer in a docker-compose.yml file with a volume mounted, similar as i would do for adminer with mysql. Update: Today i would rather use the IntelliJ Database Tool for &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2019/10/23/adminer-for-sqlite-in-docker/" class="more-link">Continue reading<span class="screen-reader-text"> "Adminer for Sqlite in Docker"</span></a></p>
The post <a href="https://nerdpress.org/2019/10/23/adminer-for-sqlite-in-docker/">Adminer for Sqlite in Docker</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>Recently i wanted to use Sqlite with <a aria-label="Adminer (opens in a new tab)" href="https://www.adminer.org/" target="_blank" rel="noreferrer noopener">Adminer</a> in Docker and it turned out to be not so easy.<br /> I actually thought i could just declare Adminer in a docker-compose.yml file with a volume mounted, similar as i would do for adminer with mysql.</p>



<p><strong>Update</strong>: Today i would rather use the <a href="https://nerdpress.org/2021/05/17/sqlite-administration-in-intellij-ide/">IntelliJ Database Tool for Sqlite administration</a>.</p>



<p>But since Adminer is a popular hacking target they introduced a <a href="https://www.adminer.org/en/password/" target="_blank" rel="noreferrer noopener" aria-label="feature (opens in a new tab)">feature</a> that does not allow to run adminer without a password, out of the box.<br /> Sqlite database usually runs without password and dang, workaround needed!</p>



<span id="more-2889"></span>



<p>So we need to add a plugin to adminer that allows password-less login and extend the official Adminer Docker image to include the plugin.</p>



<p>We add a script that loads the official password-less-login plugin and copy it to the plugins-enabled folder of the Adminer image</p>



<p>login-password-less.php:</p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:100%"><div class="wp-block-syntaxhighlighter-code "><pre class="brush: php; title: ; notranslate">
&lt;?php
require_once(&#039;plugins/login-password-less.php&#039;);

/** Set allowed password
 * @param string result of password_hash
 */
return new AdminerLoginPasswordLess(
    $password_hash = password_hash(&quot;admin&quot;, PASSWORD_DEFAULT)
);
</pre></div></div>
</div>



<p>Dockerfile:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
FROM adminer
USER root
COPY login-password-less.php /var/www/html/plugins-enabled/login-password-less.php
#USER adminer # we run as root because of permissions problems on db file with the volume
</pre></div>


<p>In docker-compose.yml:</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: yaml; title: ; notranslate">
version: &quot;3&quot;
services:
  app:
    build: ./php
      - mailcatcher
    volumes:
      - &quot;../:/app:rw&quot;
      - &quot;./php/cli/php.ini:/etc/php/7.3/cli/php.ini:ro&quot;
      - &quot;./php/fpm/php.ini:/etc/php/7.3/fpm/php.ini:ro&quot;

  nginx:
    build: ./nginx
    depends_on:
      - app
    command: /bin/sh -c &quot;nginx -g &#039;daemon off;&#039;&quot;
    volumes:
      - &quot;..:/app:rw&quot;
      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
    ports:
      - &#039;8088:80&#039;

  adminer:
    build: ./adminer
    restart: unless-stopped
    volumes:
      - &quot;..:/app:rw&quot;
    ports:
      - 8080:8080
</pre></div>


<p>File tree:</p>



<ul class="wp-block-list"><li>adminer<br />&#8211; Dockerfile<br />&#8211; login-password-less.php</li><li>nginx<br />&#8230;</li><li>php<br />&#8230;</li><li>docker-compose.yml</li></ul>



<p><em>Note that since docker-compose.yml version 3 the volumes_from directive was removed in favor of top level volumes to share volumes across images. However this implementation is imho rather weird, so i jut duplicated the volumes declaration in the App container and Adminer container.<br /> Feels rather wrong but thats all i could come up with. Any advice here is welcome.</em></p>



<p>Now that this is done we can open the Sqlite3 database with the pseudo-password &#8220;admin&#8221; and manage the database.</p>



<p>After all you could also just copy the one-file Adminer with plugin to the php container and run it from within the php container. Just adjust your Nginx config to allow calling the file directly and take care to not deploy Adminer to live.<br /> There is also a project that bundles the plugin with Adminer to one file: <a href="https://github.com/FrancoisCapon/LoginToASqlite3DatabaseWithoutCredentialsWithAdminer" target="_blank" rel="noreferrer noopener">https://github.com/FrancoisCapon/LoginToASqlite3DatabaseWithoutCredentialsWithAdminer/blob/master/build-adminer-4-sqlite3-into-one-file.sh</a></p>The post <a href="https://nerdpress.org/2019/10/23/adminer-for-sqlite-in-docker/">Adminer for Sqlite in Docker</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
