1

I would like to deploy a spring boot application into a docker container. I had created the base image using Alpine Linux. My old configuration runs a service on Red Hat under this path /etc/systemd/system/service.service.

I am wondering if this is a good approach to create the service into the container or leave the management responsibility of the service to the Docker composer.

Here is the service in Redhat:

[Unit]
 Description=service description

[Service]
WorkingDirectory=dir
ExecStart=/bin/bash -c "java -Xmx512m -jar ms-service-0.0.1.jar"
Restart=on-failure
[Install]

I have in my Dockerfile

ENTRYPOINT ["java","-Xmx512m","-jar","/usr/src/service/ms-service-0.0.1.jar"]
  • 3
    If you are moving your application into Docker, as I think you are suggesting you are doing, then you use a CMD or ENTRYPOINT to start the application. As I understand it, the application must be PID 1, and the application must not exit (until desired). So you would not use a service inside of Docker. Docker will start/stop the container, and the container should only execute the application. – KevinO Sep 13 '18 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.