title: can't connect to docker container localhost connection refused
body: <p>very new to docker. following this tutorial: <a href="https://medium.com/thecodefountain/develop-a-spring-boot-and-mysql-application-and-run-in-docker-end-to-end-15b7cdf3a2ba" rel="nofollow noreferrer">https://medium.com/thecodefountain/develop-a-spring-boot-and-mysql-application-and-run-in-docker-end-to-end-15b7cdf3a2ba</a></p>
  <p>I followed all the instructions (my application is called <code>accessing-data-mysql</code>) but I think I should have two containers running: one for mysql and one for the application. But when running <code>docker container ls</code> I only see the mysql container listed. Below I am creating a docker container for my application's image and linking it to the running instance of mysql container.</p>
  <pre><code>PS C:\projects\project1&gt; docker run -d -p 8089:8089 --name accessing-data-mysql --link mysql-standalone:mysql accessing-data-mysql
  82f499c6897d1f6bd2eeaabe4aa25ae786508146929a7039785e4ca37d691435
  PS C:\projects\project1&gt; docker container ls
  CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                 NAMES
  62029a53b9d4        mysql               &quot;docker-entrypoint.s…&quot;   16 minutes ago      Up 16 minutes       3306/tcp, 33060/tcp   mysql-standalone
  PS C:\projects\project1&gt; docker run -d -p 8089:8089 --name accessing-data-mysql --link mysql-standalone:mysql accessing-data-mysql
  </code></pre>
  <p>my docker file:</p>
  <pre><code>FROM openjdk:12
  ADD target/user-mysql.jar user-mysql.jar
  EXPOSE 8089
  ENTRYPOINT [&quot;java&quot;, &quot;-jar&quot;, &quot;user-mysql.jar&quot;]
  </code></pre>
  <p>when connecting via browser to localhost:8089, I get connection refused error. Not even sure if the service is running.</p>
  <p>below is the result of running docker logs:</p>
  <pre><code>PS C:\projects\project1&gt; docker ps -a
  CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS                      PORTS                 NAMES
  82f499c6897d        accessing-data-mysql   &quot;java -jar accessing…&quot;   50 minutes ago      Exited (0) 50 minutes ago                         accessing-data-mysql
  62029a53b9d4        mysql                  &quot;docker-entrypoint.s…&quot;   About an hour ago   Up About an hour            3306/tcp, 33060/tcp   mysql-standalone
  PS C:\projects\project1&gt; docker logs accessing-data-mysql
  Hibernate ORM core version 5.4.27.Final
  PS C:\projects\project1&gt;
  </code></pre>
  <p>EDIT:
  When I run locally directly from Idea, I see the error: No such host is known (mysql-standalone), which is the mysql url I configured to connect to docker mysql. As soon as I change the mysql url to localhost:3306, it can connect. Does this mean that somehow the my-sql docker instance is not accepting connections?</p>