title: Unable to Run Container Using testcontainers
body: <p>I'm trying to implement a JUnit (v4.13.2) test using <a href="https://www.testcontainers.org/" rel="nofollow noreferrer">testcontainers</a> (v1.16.2) to better test our DAO/JPA classes. I'm using the centos/postgresql-96-centos7 official docker image and I can run it on the cmd line just fine using: <code>docker run -d --name postgres -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRES_DATABASE=db -p 5432:5432 centos/postgresql-96-centos7</code>. I removed the container prior to running the unit test to avoid any conflicts in my docker environment. However, when I run my test, I consistently get the following errors:</p>
  <pre><code>java.lang.ExceptionInInitializerError
  Caused by: org.testcontainers.containers.ContainerLaunchException: Container startup failed
  Caused by: org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
  Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
  Caused by: java.lang.IllegalStateException: Container exited with code 2
  </code></pre>
  <p>I have tried increasing the timeout value to 5 mins and simplified to the JUnit4 testing pattern (to avoid running a mixed testing environment) to no avail. I'm only including the code for the abstract class because it is throwing the exception before calling <code>POSTGRESQL_CONTAINER.start()</code>.</p>
  <pre><code>public abstract class AbstractRdbmsTest {
      private static final String DOCKER_IMAGE_NAME = &quot;centos/postgresql-96-centos7&quot;;
      private static final String POSTGRESQL_USER = &quot;user&quot;;
      private static final String POSTGRESQL_PASSWORD = &quot;pass&quot;;
      private static final String POSTGRESQL_DATABASE = &quot;db&quot;;
  
      protected static final PostgreSQLContainer POSTGRESQL_CONTAINER;
  
      static {
          DockerImageName imgName = DockerImageName.parse(DOCKER_IMAGE_NAME).asCompatibleSubstituteFor(&quot;postgres&quot;);
  
          POSTGRESQL_CONTAINER = (PostgreSQLContainer) new PostgreSQLContainer(imgName)
                  .withDatabaseName(POSTGRESQL_DATABASE)
                  .withUsername(POSTGRESQL_USER)
                  .withPassword(POSTGRESQL_PASSWORD)
                  .withExposedPorts(PostgreSQLContainer.POSTGRESQL_PORT);
  
          POSTGRESQL_CONTAINER.start();
      }
  }
  </code></pre>
  <p>EDIT: Local Docker Env:
  Client/Server: Docker Engine - Community v20.10.7</p>