title: Docker container is running without port mapping
body: <p>I created a docker-compose file to build image from dockerfile and then run container this is my code:</p>
  <p>Dockerfile</p>
  <pre><code>FROM anapsix/alpine-java
  
  VOLUME [ &quot;/var/run/jars/&quot; ]
  
  ADD hello-world.jar /var/run/jars/
  
  EXPOSE 8080
  ENTRYPOINT [ &quot;java&quot; ]
  CMD [&quot;-?&quot;]
  </code></pre>
  <p>docker-compose.yml</p>
  <pre><code>version: '3'
  services:
    hello-world-image:
     build: .
     image: hello-world-image    
    hello-world:
     image: hello-world-image
     container_name: hello-world
     ports:
      - &quot;8080:8080&quot;
     volumes:
       - ./logs_ACM:/root/logs_ACM
     command: -jar /var/run/jars/hello-world.jar
     restart: always
  </code></pre>
  <p>docker ps output:</p>
  <pre><code>CONTAINER ID   IMAGE               COMMAND                  CREATED         STATUS                                  PORTS     NAMES
  103b0a3c30e3   hello-world-image   &quot;java -jar /var/run/…&quot;   5 seconds ago   Restarting (1) Less than a second ago             hello-world
  </code></pre>
  <p>When i check running containers with &quot;docker ps&quot; the port column is empty therefore no port mapping was done even though i specified ports in my docker compose file.
  What changes needed to be done on my docker-compose file to solve this issue ?</p>
  <p>new version of dockerfile and docker-compose :</p>
  <pre><code>FROM anapsix/alpine-java
  
  USER root
  
  RUN mkdir -p /var/run/jars/
  
  COPY spring-petclinic-2.4.2.jar /var/run/jars/
  
  EXPOSE 8081
  
  ENTRYPOINT [ &quot;java&quot; ]
  
  CMD [&quot;-?&quot;]
  
  version: '3'  # '3' means '3.0'
  services:
  spring-petclinic:
   build: .
  # Only if you're planning to `docker-compose push`
  # image: registry.example.com/name/hello-world-image:${TAG:-latest}
   ports:
    - &quot;8081:8081&quot;
   volumes:
   # A bind-mount directory to read out log files is a good use of
   # `volumes:`.  This does not require special setup in the Dockerfile.
    - ./logs_ACM:/root/logs_ACM
   command: -jar /var/run/jars/spring-petclinic-2.4.2.jar
  mysql:
   image: mysql:5.7
   ports:
    - &quot;3306:3306&quot;
   environment:
    - MYSQL_ROOT_PASSWORD=
    - MYSQL_ALLOW_EMPTY_PASSWORD=true
    - MYSQL_USER=petclinic
    - MYSQL_PASSWORD=petclinic
    - MYSQL_DATABASE=petclinic
   volumes:
    - &quot;./conf.d:/etc/mysql/conf.d:ro&quot;
  </code></pre>