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 ?
what you’re seeing is the “running” container, is your build container, but its not the right way to do it, you should skip the “build” container and instead move the build part, to your main container, like:
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 [ "java" ]
CMD ["-?"]
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:
- "8081:8081"
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:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD=
- MYSQL_ALLOW_EMPTY_PASSWORD=true
- MYSQL_USER=petclinic
- MYSQL_PASSWORD=petclinic
- MYSQL_DATABASE=petclinic
volumes:
- "./conf.d:/etc/mysql/conf.d:ro"