title: Trying to connect to mariadb running in docker
body: <p>I have a database running in a docker container. It does not publish mariadb's port 3306.</p>
  
  <p>Now I want to remotely log in to the docker host, connect to the container and access the database from my laptop</p>
  
  <pre><code>laptop ---&gt; dockerhost ---&gt; container
  </code></pre>
  
  <p>in order to access the database with gUI tools like DbVisualizer.</p>
  
  <p>The idea is to open a connection with socat, but I'm stuck. Basically something like:</p>
  
  <pre><code>socat TCP4-LISTEN:3306 EXEC:'ssh dockerhost sudo docker exec container "socat - TCP:localhost:3306"'
  </code></pre>
  
  <p>The last attempt failed with "Unexpected exception encountered during query." in DbVisualizer and "2019/09/10 12:19:54 socat[17462] E write(6, 0x7f9985803c00, 114): Broken pipe" in the shell.</p>
  
  <p>The command was (broken for readability):</p>
  
  <pre><code>socat TCP4-LISTEN:3306,forever,reuseaddr,fork \
  exec:'
      ssh dockerhost \
          sudo docker exec container "
              socat STDIO TCP:localhost:3306,forever,reuseaddr,fork
          "
  '
  </code></pre>
  
  <p>I hope someone can pinpoint what I do wrong or tell me how I can achieve my goal.</p>