<?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/docker/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>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>
		<item>
		<title>Not allowed to connect to Mysql error in docker</title>
		<link>https://nerdpress.org/2017/09/07/not-allowed-connect-mysql-error-docker/</link>
					<comments>https://nerdpress.org/2017/09/07/not-allowed-connect-mysql-error-docker/#comments</comments>
		
		<dc:creator><![CDATA[Ivo Bathke]]></dc:creator>
		<pubDate>Thu, 07 Sep 2017 10:58:57 +0000</pubDate>
				<category><![CDATA[docker]]></category>
		<guid isPermaLink="false">https://nerdpress.org/?p=2765</guid>

					<description><![CDATA[<p>From time to time i receive this error while running the official mysql image in docker: An exception occured in driver: SQLSTATE[HY000] [1130] Host &#8216;172.17.0.5&#8217; is not allowed to connect to this MySQL server The reason for this is not quite clear yet but i usually resolve it like described here. Note that all data &#8230; </p>
<p class="link-more"><a href="https://nerdpress.org/2017/09/07/not-allowed-connect-mysql-error-docker/" class="more-link">Continue reading<span class="screen-reader-text"> "Not allowed to connect to Mysql error in docker"</span></a></p>
The post <a href="https://nerdpress.org/2017/09/07/not-allowed-connect-mysql-error-docker/">Not allowed to connect to Mysql error in docker</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></description>
										<content:encoded><![CDATA[<p>From time to time i receive this error while running the official mysql image in docker:</p>
<blockquote><p>An exception occured in driver: SQLSTATE[HY000] [1130] Host &#8216;172.17.0.5&#8217; is<br />
   not allowed to connect to this MySQL server </p></blockquote>
<p>The reason for this is not quite clear yet but i usually resolve it like described here.<br />
<strong>Note that all data stored in the project will be lost!</strong><br />
So this error is quite annyoing but luckily i work on fixtures so i can restore data easily.<br />
These steps let me connect to the mysql container again, at least.</p>
<p><span id="more-2765"></span></p>
<p>1. Run an inspection on the mysql container:</p>
<pre class="brush: bash; title: ; notranslate">docker inspect my-project-with-mysql</pre>
<p>And search for the data mounts of the mysql container to know where the data is stored on my machine because i need to delete them, aargh:</p>
<pre class="brush: jscript; title: ; notranslate">
{
   &quot;Mounts&quot;:&#x5B;
      {
         &quot;Type&quot;:&quot;volume&quot;,
         &quot;Name&quot;:&quot;db9aa2f8a43c08&quot;,
         &quot;Source&quot;:&quot;/var/lib/docker/volumes/db9aa2f8a43c08/_data&quot;,
         &quot;Destination&quot;:&quot;/var/lib/mysql&quot;,
         &quot;Driver&quot;:&quot;local&quot;,
         &quot;Mode&quot;:&quot;&quot;,
         &quot;RW&quot;:true,
         &quot;Propagation&quot;:&quot;&quot;
      }
   ]
}
</pre>
<p>The path can be found in the &#8220;Source&#8221; property.</p>
<p>2. Now i remove all containers to start anew:</p>
<pre class="brush: bash; title: ; notranslate">docker-compose rm my-project-with-mysql</pre>
<p>3. Then i remove all data in the mysql container. My assumption is that somehow the data in the system tables got corrupted.<br />
So delete all contents and restore the directory:</p>
<pre class="brush: bash; title: ; notranslate">
sudo rm -rf /var/lib/docker/volumes/db9aa2f8a43c08/_data
sudo mkdir /var/lib/docker/volumes/db9aa2f8a43c08/_data
</pre>
<p>4. Finally rebuild the containers</p>
<pre class="brush: bash; title: ; notranslate">
docker-compose build
docker-compose up
</pre>
<p>5. Now i run the scripts that will populate the database from the fixtures again and the problem is fixed.</p>
<p>If you know the reason for this error please let me know.</p>The post <a href="https://nerdpress.org/2017/09/07/not-allowed-connect-mysql-error-docker/">Not allowed to connect to Mysql error in docker</a> first appeared on <a href="https://nerdpress.org">Nerdpress.org</a>.]]></content:encoded>
					
					<wfw:commentRss>https://nerdpress.org/2017/09/07/not-allowed-connect-mysql-error-docker/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
