I created a docker-compose file to build image from dockerfile and then run container this is my code:
FROM anapsix/alpine-java VOLUME [ "/var/run/jars/" ] ADD hello-world.jar /var/run/jars/ EXPOSE 8080 ENTRYPOINT [ "java" ] CMD ["-?"]
version: '3' services: hello-world-image: build: . image: hello-world-image hello-world: image: hello-world-image container_name: hello-world ports: - "8080:8080" volumes: - ./logs_ACM:/root/logs_ACM command: -jar /var/run/jars/hello-world.jar restart: always
docker ps output:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 103b0a3c30e3 hello-world-image "java -jar /var/run/…" 5 seconds ago Restarting (1) Less than a second ago hello-world
When i check running containers with “docker ps” 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 ?