Restarting Play application Docker container results in 'This application is already running' - RUNNING_PID is not deleted The Next CEO of Stack OverflowPlay change RUNNING_PID file pathUnexpected JVM exit after first docker process is completedGetting “This application is already running”, but can't find RUNNING_PITHow to list containers in DockerHow to remove old Docker containersRun a Docker Image as a ContainerHow to enter in a Docker container already running with a new TTYCopying files from Docker container to hostCopying files from host to Docker containerWhat is the difference between a Docker image and a container?From inside of a Docker container, how do I connect to the localhost of the machine?How do I run a command on an already existing Docker container?AWS EB, Play Framework and Docker: Application Already running
Can Sri Krishna be called 'a person'?
Strange use of "whether ... than ..." in official text
How can I separate the number from the unit in argument?
Are British MPs missing the point, with these 'Indicative Votes'?
How to show a landlord what we have in savings?
How to find if SQL server backup is encrypted with TDE without restoring the backup
What steps are necessary to read a Modern SSD in Medieval Europe?
Simplify trigonometric expression using trigonometric identities
Can this transistor (2n2222) take 6V on emitter-base? Am I reading datasheet incorrectly?
How dangerous is XSS
Incomplete cube
Could a dragon use its wings to swim?
What day is it again?
How to pronounce fünf in 45
Is it OK to decorate a log book cover?
Can I cast Thunderwave and be at the center of its bottom face, but not be affected by it?
Cannot restore registry to default in Windows 10?
logical reads on global temp table, but not on session-level temp table
How to implement Comparable so it is consistent with identity-equality
Planeswalker Ability and Death Timing
Can a PhD from a non-TU9 German university become a professor in a TU9 university?
What does this strange code stamp on my passport mean?
Early programmable calculators with RS-232
How seriously should I take size and weight limits of hand luggage?
Restarting Play application Docker container results in 'This application is already running' - RUNNING_PID is not deleted
The Next CEO of Stack OverflowPlay change RUNNING_PID file pathUnexpected JVM exit after first docker process is completedGetting “This application is already running”, but can't find RUNNING_PITHow to list containers in DockerHow to remove old Docker containersRun a Docker Image as a ContainerHow to enter in a Docker container already running with a new TTYCopying files from Docker container to hostCopying files from host to Docker containerWhat is the difference between a Docker image and a container?From inside of a Docker container, how do I connect to the localhost of the machine?How do I run a command on an already existing Docker container?AWS EB, Play Framework and Docker: Application Already running
Edit: There is a related issue being discussed on Github but in another mode of deployment (Typesafe Activator UI and not Docker).
I was trying to simulate a system reboot in order to verify the Docker restart policy which declares to be able to re-run containers in the correct order.
I have a Play framework application written in Java.
The Dockerfile looks like this:
FROM ubuntu:14.04
#
# [Java8, ...]
#
RUN chmod +x /opt/bin/playapp
CMD ["/bin/bash"]
I start it using $ docker run --restart=always -d --name playappcontainer "./opt/bin/playapp"
.
When I $ service docker stop && service docker restart
and then $ docker attach playappcontainer
the console tells me:
Play server process ID is 7
This application is already running (Or delete /opt/RUNNING_PID file)
Edit: Same result when I follow the recommendation of the Play documentation to change the location of the file to /var/run/play.pid with -Dpidfile.path=/var/run/play.pid
.
Play server process ID is 7
This application is already running (Or delete /var/run/play.pid file).
So: Why is the file containing the RUNNING_PID not deleted when the docker daemon stops, gets restartet and restarts previously run containers?
When I $ docker inspect playappcontainer
, it tells me:
"State":
"ExitCode": 255,
"FinishedAt": "2015-02-05T17:52:39.150013995Z",
"Paused": false,
"Pid": 0,
"Restarting": true,
"Running": true,
"StartedAt": "2015-02-05T17:52:38.479446993Z"
,
Although:
The main process inside the container will receive SIGTERM, and after
a grace period, SIGKILL.
from the Docker reference on $ docker stop
To kill a running Play server, it is enough to send a SIGTERM to the
process to properly shutdown the application.
from the Play Framework documentation on stopping a Play application
java playframework playframework-2.0 docker playframework-2.3
add a comment |
Edit: There is a related issue being discussed on Github but in another mode of deployment (Typesafe Activator UI and not Docker).
I was trying to simulate a system reboot in order to verify the Docker restart policy which declares to be able to re-run containers in the correct order.
I have a Play framework application written in Java.
The Dockerfile looks like this:
FROM ubuntu:14.04
#
# [Java8, ...]
#
RUN chmod +x /opt/bin/playapp
CMD ["/bin/bash"]
I start it using $ docker run --restart=always -d --name playappcontainer "./opt/bin/playapp"
.
When I $ service docker stop && service docker restart
and then $ docker attach playappcontainer
the console tells me:
Play server process ID is 7
This application is already running (Or delete /opt/RUNNING_PID file)
Edit: Same result when I follow the recommendation of the Play documentation to change the location of the file to /var/run/play.pid with -Dpidfile.path=/var/run/play.pid
.
Play server process ID is 7
This application is already running (Or delete /var/run/play.pid file).
So: Why is the file containing the RUNNING_PID not deleted when the docker daemon stops, gets restartet and restarts previously run containers?
When I $ docker inspect playappcontainer
, it tells me:
"State":
"ExitCode": 255,
"FinishedAt": "2015-02-05T17:52:39.150013995Z",
"Paused": false,
"Pid": 0,
"Restarting": true,
"Running": true,
"StartedAt": "2015-02-05T17:52:38.479446993Z"
,
Although:
The main process inside the container will receive SIGTERM, and after
a grace period, SIGKILL.
from the Docker reference on $ docker stop
To kill a running Play server, it is enough to send a SIGTERM to the
process to properly shutdown the application.
from the Play Framework documentation on stopping a Play application
java playframework playframework-2.0 docker playframework-2.3
add a comment |
Edit: There is a related issue being discussed on Github but in another mode of deployment (Typesafe Activator UI and not Docker).
I was trying to simulate a system reboot in order to verify the Docker restart policy which declares to be able to re-run containers in the correct order.
I have a Play framework application written in Java.
The Dockerfile looks like this:
FROM ubuntu:14.04
#
# [Java8, ...]
#
RUN chmod +x /opt/bin/playapp
CMD ["/bin/bash"]
I start it using $ docker run --restart=always -d --name playappcontainer "./opt/bin/playapp"
.
When I $ service docker stop && service docker restart
and then $ docker attach playappcontainer
the console tells me:
Play server process ID is 7
This application is already running (Or delete /opt/RUNNING_PID file)
Edit: Same result when I follow the recommendation of the Play documentation to change the location of the file to /var/run/play.pid with -Dpidfile.path=/var/run/play.pid
.
Play server process ID is 7
This application is already running (Or delete /var/run/play.pid file).
So: Why is the file containing the RUNNING_PID not deleted when the docker daemon stops, gets restartet and restarts previously run containers?
When I $ docker inspect playappcontainer
, it tells me:
"State":
"ExitCode": 255,
"FinishedAt": "2015-02-05T17:52:39.150013995Z",
"Paused": false,
"Pid": 0,
"Restarting": true,
"Running": true,
"StartedAt": "2015-02-05T17:52:38.479446993Z"
,
Although:
The main process inside the container will receive SIGTERM, and after
a grace period, SIGKILL.
from the Docker reference on $ docker stop
To kill a running Play server, it is enough to send a SIGTERM to the
process to properly shutdown the application.
from the Play Framework documentation on stopping a Play application
java playframework playframework-2.0 docker playframework-2.3
Edit: There is a related issue being discussed on Github but in another mode of deployment (Typesafe Activator UI and not Docker).
I was trying to simulate a system reboot in order to verify the Docker restart policy which declares to be able to re-run containers in the correct order.
I have a Play framework application written in Java.
The Dockerfile looks like this:
FROM ubuntu:14.04
#
# [Java8, ...]
#
RUN chmod +x /opt/bin/playapp
CMD ["/bin/bash"]
I start it using $ docker run --restart=always -d --name playappcontainer "./opt/bin/playapp"
.
When I $ service docker stop && service docker restart
and then $ docker attach playappcontainer
the console tells me:
Play server process ID is 7
This application is already running (Or delete /opt/RUNNING_PID file)
Edit: Same result when I follow the recommendation of the Play documentation to change the location of the file to /var/run/play.pid with -Dpidfile.path=/var/run/play.pid
.
Play server process ID is 7
This application is already running (Or delete /var/run/play.pid file).
So: Why is the file containing the RUNNING_PID not deleted when the docker daemon stops, gets restartet and restarts previously run containers?
When I $ docker inspect playappcontainer
, it tells me:
"State":
"ExitCode": 255,
"FinishedAt": "2015-02-05T17:52:39.150013995Z",
"Paused": false,
"Pid": 0,
"Restarting": true,
"Running": true,
"StartedAt": "2015-02-05T17:52:38.479446993Z"
,
Although:
The main process inside the container will receive SIGTERM, and after
a grace period, SIGKILL.
from the Docker reference on $ docker stop
To kill a running Play server, it is enough to send a SIGTERM to the
process to properly shutdown the application.
from the Play Framework documentation on stopping a Play application
java playframework playframework-2.0 docker playframework-2.3
java playframework playframework-2.0 docker playframework-2.3
edited Feb 15 '15 at 10:42
Steven
asked Feb 5 '15 at 18:29
StevenSteven
4762823
4762823
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
I've just dockerized a Play! application and was also running into this issue - restarting the host caused the Play! application to fail to start in its container because RUNNING_PID
had not been deleted.
It occurred to me that as the Play! application is the only process within its container, always has the same PID, and is taken care of by Docker, the RUNNING_PID
file is (to the best of my knowledge) not actually needed.
As such I overrode pidfile.path
to /dev/null
by placing
javaOptions in Universal ++= Seq(
"-Dpidfile.path=/dev/null"
)
in my project's build.sbt. And it works - I can reboot the host (and container) and my Play! application starts up fine.
The appeal for me of this approach is it does not require changing the way the image itself is produced by sbt-native-packager, just the way the application runs within it.
This works with sbt-native-packager 1.0.0-RC2 and higher (because that release includes https://github.com/sbt/sbt-native-packager/pull/510).
+1 This solution worked for me. Alternatively after updating the native packager you can add an application.ini file instead of having this in the build script. I went with that option.
– Chris Dail
May 25 '15 at 17:27
+1 I really don't understand why they can't keep up without breaking Upstart on every new release.
– danielnegri
Jul 1 '15 at 19:07
1
Just a check, should setting pidfile.path=/dev/null be enough in reference.conf / application.conf?
– Touko
Feb 19 '16 at 12:59
1
I just tested it, and can confirm it works in that no RUNNING_PID file is created at/opt/docker/RUNNING_PID
when I run a container that has such a configuration. However, the difference is that setting it in a.conf
like this will make it apply in all run/deployment modes (even those where the PID file is required), whereas doing it inbuild.sbt
, qualified byin Universal
means it is only applied to sbt-native-packager deployments.
– dhpiggott
Mar 5 '16 at 13:28
add a comment |
I sorted out a working workaround based on the answers and my further work on this question. If I start the containers as follows, they'll be up after an (un)expected stop/restart. The conflicting RUNNING_PID file won't prevent the container from restarting.
$ sudo docker run --restart=on-failure:5 -d
--name container my_/container:latest
sh -c "rm -f /var/run/play.pid && ./opt/bin/start
-Dpidfile.path=/var/run/play.pid"
What it does is deleting the file containing the process ID which is put at a specific place using an option everytime before running the binary.
add a comment |
I had the exact same problem and worked my way around it by manually deleting the file every time the container would run.
In order to do that I added in a companion file "start.bash" I use to start the play process from the results of the SBT dist task, the following line:
find . -type f -name RUNNING_PID -exec rm -f ;
Hope it helps.
1
Hi Julian, thanks for this. I actually do use a star.sh script to to kill and run the containers (the application is stateless, so that's not a problem in terms of data). But this is some kind of dirty. Do you know if there is a way to run this line inside the container automatically upon every restart?
– Steven
Feb 13 '15 at 17:52
Well... actually that's what I intend to do with that line. My applications are stateless too, so every time a container starts, this RUNNING_PID file gets removed and a new one with a different identifier gets created. I know it's not the most elegant thing in the world though. I don't know as of now of any other way of accomplishing the same in a more natural way using docker.
– Julian Hernandez
Feb 14 '15 at 22:33
But we agree on the fact that this is not a misbehaviour of Docker but of Play, right?
– Steven
Feb 15 '15 at 1:25
1
Yes, we definitely do :)
– Julian Hernandez
Feb 15 '15 at 6:59
add a comment |
I don't know much about docker, but Play does not remove RUNNING_PID
on stopping the server as far as I have tested. When I deployed my app in prod
mode and try to stop it by Ctrl+D
and Ctrl+C
it din't remove the RUNNING_PID file from project directory so I had to manually delete it. From Play docs
Normally this(RUNNING_PID) file is placed in the root directory of your play
project, however it is advised that you put it somewhere where it will
be automatically cleared on restart, such as/var/run
:
So - apart from manual deletion - the workaround is to change the path of RUNNING_PID and delete it every time the server starts through some script.
$ /path/to/bin/<project-name> -Dpidfile.path=/var/run/play.pid
Make sure that the directory exists and that the user that runs the Play application has write permission for it.
Using this file, you can stop your application using the kill command, for example:
$ kill $(cat /var/run/play.pid)
and you can also try docker command $ sudo docker rm --force redis
Maybe That could help
Source1 Source2 Source3
Hello singhakash, thank you for your answer. I already developed a workaround by an external script which kills the container on restart and restarts it. But this is not satisfying for me. Also, as you can see in my question, I already changed the location of the RUNNING_PID file. As I pointed out in my expectations I would like to have a restarting Docker container, not to kill it and then run it again. It is part of a larger infrastructure and other components rely on its presence.
– Steven
Feb 11 '15 at 10:13
add a comment |
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f28351405%2frestarting-play-application-docker-container-results-in-this-application-is-alr%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
I've just dockerized a Play! application and was also running into this issue - restarting the host caused the Play! application to fail to start in its container because RUNNING_PID
had not been deleted.
It occurred to me that as the Play! application is the only process within its container, always has the same PID, and is taken care of by Docker, the RUNNING_PID
file is (to the best of my knowledge) not actually needed.
As such I overrode pidfile.path
to /dev/null
by placing
javaOptions in Universal ++= Seq(
"-Dpidfile.path=/dev/null"
)
in my project's build.sbt. And it works - I can reboot the host (and container) and my Play! application starts up fine.
The appeal for me of this approach is it does not require changing the way the image itself is produced by sbt-native-packager, just the way the application runs within it.
This works with sbt-native-packager 1.0.0-RC2 and higher (because that release includes https://github.com/sbt/sbt-native-packager/pull/510).
+1 This solution worked for me. Alternatively after updating the native packager you can add an application.ini file instead of having this in the build script. I went with that option.
– Chris Dail
May 25 '15 at 17:27
+1 I really don't understand why they can't keep up without breaking Upstart on every new release.
– danielnegri
Jul 1 '15 at 19:07
1
Just a check, should setting pidfile.path=/dev/null be enough in reference.conf / application.conf?
– Touko
Feb 19 '16 at 12:59
1
I just tested it, and can confirm it works in that no RUNNING_PID file is created at/opt/docker/RUNNING_PID
when I run a container that has such a configuration. However, the difference is that setting it in a.conf
like this will make it apply in all run/deployment modes (even those where the PID file is required), whereas doing it inbuild.sbt
, qualified byin Universal
means it is only applied to sbt-native-packager deployments.
– dhpiggott
Mar 5 '16 at 13:28
add a comment |
I've just dockerized a Play! application and was also running into this issue - restarting the host caused the Play! application to fail to start in its container because RUNNING_PID
had not been deleted.
It occurred to me that as the Play! application is the only process within its container, always has the same PID, and is taken care of by Docker, the RUNNING_PID
file is (to the best of my knowledge) not actually needed.
As such I overrode pidfile.path
to /dev/null
by placing
javaOptions in Universal ++= Seq(
"-Dpidfile.path=/dev/null"
)
in my project's build.sbt. And it works - I can reboot the host (and container) and my Play! application starts up fine.
The appeal for me of this approach is it does not require changing the way the image itself is produced by sbt-native-packager, just the way the application runs within it.
This works with sbt-native-packager 1.0.0-RC2 and higher (because that release includes https://github.com/sbt/sbt-native-packager/pull/510).
+1 This solution worked for me. Alternatively after updating the native packager you can add an application.ini file instead of having this in the build script. I went with that option.
– Chris Dail
May 25 '15 at 17:27
+1 I really don't understand why they can't keep up without breaking Upstart on every new release.
– danielnegri
Jul 1 '15 at 19:07
1
Just a check, should setting pidfile.path=/dev/null be enough in reference.conf / application.conf?
– Touko
Feb 19 '16 at 12:59
1
I just tested it, and can confirm it works in that no RUNNING_PID file is created at/opt/docker/RUNNING_PID
when I run a container that has such a configuration. However, the difference is that setting it in a.conf
like this will make it apply in all run/deployment modes (even those where the PID file is required), whereas doing it inbuild.sbt
, qualified byin Universal
means it is only applied to sbt-native-packager deployments.
– dhpiggott
Mar 5 '16 at 13:28
add a comment |
I've just dockerized a Play! application and was also running into this issue - restarting the host caused the Play! application to fail to start in its container because RUNNING_PID
had not been deleted.
It occurred to me that as the Play! application is the only process within its container, always has the same PID, and is taken care of by Docker, the RUNNING_PID
file is (to the best of my knowledge) not actually needed.
As such I overrode pidfile.path
to /dev/null
by placing
javaOptions in Universal ++= Seq(
"-Dpidfile.path=/dev/null"
)
in my project's build.sbt. And it works - I can reboot the host (and container) and my Play! application starts up fine.
The appeal for me of this approach is it does not require changing the way the image itself is produced by sbt-native-packager, just the way the application runs within it.
This works with sbt-native-packager 1.0.0-RC2 and higher (because that release includes https://github.com/sbt/sbt-native-packager/pull/510).
I've just dockerized a Play! application and was also running into this issue - restarting the host caused the Play! application to fail to start in its container because RUNNING_PID
had not been deleted.
It occurred to me that as the Play! application is the only process within its container, always has the same PID, and is taken care of by Docker, the RUNNING_PID
file is (to the best of my knowledge) not actually needed.
As such I overrode pidfile.path
to /dev/null
by placing
javaOptions in Universal ++= Seq(
"-Dpidfile.path=/dev/null"
)
in my project's build.sbt. And it works - I can reboot the host (and container) and my Play! application starts up fine.
The appeal for me of this approach is it does not require changing the way the image itself is produced by sbt-native-packager, just the way the application runs within it.
This works with sbt-native-packager 1.0.0-RC2 and higher (because that release includes https://github.com/sbt/sbt-native-packager/pull/510).
edited Apr 3 '15 at 20:21
answered Mar 24 '15 at 22:24
dhpiggottdhpiggott
57359
57359
+1 This solution worked for me. Alternatively after updating the native packager you can add an application.ini file instead of having this in the build script. I went with that option.
– Chris Dail
May 25 '15 at 17:27
+1 I really don't understand why they can't keep up without breaking Upstart on every new release.
– danielnegri
Jul 1 '15 at 19:07
1
Just a check, should setting pidfile.path=/dev/null be enough in reference.conf / application.conf?
– Touko
Feb 19 '16 at 12:59
1
I just tested it, and can confirm it works in that no RUNNING_PID file is created at/opt/docker/RUNNING_PID
when I run a container that has such a configuration. However, the difference is that setting it in a.conf
like this will make it apply in all run/deployment modes (even those where the PID file is required), whereas doing it inbuild.sbt
, qualified byin Universal
means it is only applied to sbt-native-packager deployments.
– dhpiggott
Mar 5 '16 at 13:28
add a comment |
+1 This solution worked for me. Alternatively after updating the native packager you can add an application.ini file instead of having this in the build script. I went with that option.
– Chris Dail
May 25 '15 at 17:27
+1 I really don't understand why they can't keep up without breaking Upstart on every new release.
– danielnegri
Jul 1 '15 at 19:07
1
Just a check, should setting pidfile.path=/dev/null be enough in reference.conf / application.conf?
– Touko
Feb 19 '16 at 12:59
1
I just tested it, and can confirm it works in that no RUNNING_PID file is created at/opt/docker/RUNNING_PID
when I run a container that has such a configuration. However, the difference is that setting it in a.conf
like this will make it apply in all run/deployment modes (even those where the PID file is required), whereas doing it inbuild.sbt
, qualified byin Universal
means it is only applied to sbt-native-packager deployments.
– dhpiggott
Mar 5 '16 at 13:28
+1 This solution worked for me. Alternatively after updating the native packager you can add an application.ini file instead of having this in the build script. I went with that option.
– Chris Dail
May 25 '15 at 17:27
+1 This solution worked for me. Alternatively after updating the native packager you can add an application.ini file instead of having this in the build script. I went with that option.
– Chris Dail
May 25 '15 at 17:27
+1 I really don't understand why they can't keep up without breaking Upstart on every new release.
– danielnegri
Jul 1 '15 at 19:07
+1 I really don't understand why they can't keep up without breaking Upstart on every new release.
– danielnegri
Jul 1 '15 at 19:07
1
1
Just a check, should setting pidfile.path=/dev/null be enough in reference.conf / application.conf?
– Touko
Feb 19 '16 at 12:59
Just a check, should setting pidfile.path=/dev/null be enough in reference.conf / application.conf?
– Touko
Feb 19 '16 at 12:59
1
1
I just tested it, and can confirm it works in that no RUNNING_PID file is created at
/opt/docker/RUNNING_PID
when I run a container that has such a configuration. However, the difference is that setting it in a .conf
like this will make it apply in all run/deployment modes (even those where the PID file is required), whereas doing it in build.sbt
, qualified by in Universal
means it is only applied to sbt-native-packager deployments.– dhpiggott
Mar 5 '16 at 13:28
I just tested it, and can confirm it works in that no RUNNING_PID file is created at
/opt/docker/RUNNING_PID
when I run a container that has such a configuration. However, the difference is that setting it in a .conf
like this will make it apply in all run/deployment modes (even those where the PID file is required), whereas doing it in build.sbt
, qualified by in Universal
means it is only applied to sbt-native-packager deployments.– dhpiggott
Mar 5 '16 at 13:28
add a comment |
I sorted out a working workaround based on the answers and my further work on this question. If I start the containers as follows, they'll be up after an (un)expected stop/restart. The conflicting RUNNING_PID file won't prevent the container from restarting.
$ sudo docker run --restart=on-failure:5 -d
--name container my_/container:latest
sh -c "rm -f /var/run/play.pid && ./opt/bin/start
-Dpidfile.path=/var/run/play.pid"
What it does is deleting the file containing the process ID which is put at a specific place using an option everytime before running the binary.
add a comment |
I sorted out a working workaround based on the answers and my further work on this question. If I start the containers as follows, they'll be up after an (un)expected stop/restart. The conflicting RUNNING_PID file won't prevent the container from restarting.
$ sudo docker run --restart=on-failure:5 -d
--name container my_/container:latest
sh -c "rm -f /var/run/play.pid && ./opt/bin/start
-Dpidfile.path=/var/run/play.pid"
What it does is deleting the file containing the process ID which is put at a specific place using an option everytime before running the binary.
add a comment |
I sorted out a working workaround based on the answers and my further work on this question. If I start the containers as follows, they'll be up after an (un)expected stop/restart. The conflicting RUNNING_PID file won't prevent the container from restarting.
$ sudo docker run --restart=on-failure:5 -d
--name container my_/container:latest
sh -c "rm -f /var/run/play.pid && ./opt/bin/start
-Dpidfile.path=/var/run/play.pid"
What it does is deleting the file containing the process ID which is put at a specific place using an option everytime before running the binary.
I sorted out a working workaround based on the answers and my further work on this question. If I start the containers as follows, they'll be up after an (un)expected stop/restart. The conflicting RUNNING_PID file won't prevent the container from restarting.
$ sudo docker run --restart=on-failure:5 -d
--name container my_/container:latest
sh -c "rm -f /var/run/play.pid && ./opt/bin/start
-Dpidfile.path=/var/run/play.pid"
What it does is deleting the file containing the process ID which is put at a specific place using an option everytime before running the binary.
edited Apr 17 '17 at 23:27
dlite922
98931445
98931445
answered Mar 16 '15 at 13:30
StevenSteven
4762823
4762823
add a comment |
add a comment |
I had the exact same problem and worked my way around it by manually deleting the file every time the container would run.
In order to do that I added in a companion file "start.bash" I use to start the play process from the results of the SBT dist task, the following line:
find . -type f -name RUNNING_PID -exec rm -f ;
Hope it helps.
1
Hi Julian, thanks for this. I actually do use a star.sh script to to kill and run the containers (the application is stateless, so that's not a problem in terms of data). But this is some kind of dirty. Do you know if there is a way to run this line inside the container automatically upon every restart?
– Steven
Feb 13 '15 at 17:52
Well... actually that's what I intend to do with that line. My applications are stateless too, so every time a container starts, this RUNNING_PID file gets removed and a new one with a different identifier gets created. I know it's not the most elegant thing in the world though. I don't know as of now of any other way of accomplishing the same in a more natural way using docker.
– Julian Hernandez
Feb 14 '15 at 22:33
But we agree on the fact that this is not a misbehaviour of Docker but of Play, right?
– Steven
Feb 15 '15 at 1:25
1
Yes, we definitely do :)
– Julian Hernandez
Feb 15 '15 at 6:59
add a comment |
I had the exact same problem and worked my way around it by manually deleting the file every time the container would run.
In order to do that I added in a companion file "start.bash" I use to start the play process from the results of the SBT dist task, the following line:
find . -type f -name RUNNING_PID -exec rm -f ;
Hope it helps.
1
Hi Julian, thanks for this. I actually do use a star.sh script to to kill and run the containers (the application is stateless, so that's not a problem in terms of data). But this is some kind of dirty. Do you know if there is a way to run this line inside the container automatically upon every restart?
– Steven
Feb 13 '15 at 17:52
Well... actually that's what I intend to do with that line. My applications are stateless too, so every time a container starts, this RUNNING_PID file gets removed and a new one with a different identifier gets created. I know it's not the most elegant thing in the world though. I don't know as of now of any other way of accomplishing the same in a more natural way using docker.
– Julian Hernandez
Feb 14 '15 at 22:33
But we agree on the fact that this is not a misbehaviour of Docker but of Play, right?
– Steven
Feb 15 '15 at 1:25
1
Yes, we definitely do :)
– Julian Hernandez
Feb 15 '15 at 6:59
add a comment |
I had the exact same problem and worked my way around it by manually deleting the file every time the container would run.
In order to do that I added in a companion file "start.bash" I use to start the play process from the results of the SBT dist task, the following line:
find . -type f -name RUNNING_PID -exec rm -f ;
Hope it helps.
I had the exact same problem and worked my way around it by manually deleting the file every time the container would run.
In order to do that I added in a companion file "start.bash" I use to start the play process from the results of the SBT dist task, the following line:
find . -type f -name RUNNING_PID -exec rm -f ;
Hope it helps.
answered Feb 12 '15 at 23:29
Julian HernandezJulian Hernandez
963
963
1
Hi Julian, thanks for this. I actually do use a star.sh script to to kill and run the containers (the application is stateless, so that's not a problem in terms of data). But this is some kind of dirty. Do you know if there is a way to run this line inside the container automatically upon every restart?
– Steven
Feb 13 '15 at 17:52
Well... actually that's what I intend to do with that line. My applications are stateless too, so every time a container starts, this RUNNING_PID file gets removed and a new one with a different identifier gets created. I know it's not the most elegant thing in the world though. I don't know as of now of any other way of accomplishing the same in a more natural way using docker.
– Julian Hernandez
Feb 14 '15 at 22:33
But we agree on the fact that this is not a misbehaviour of Docker but of Play, right?
– Steven
Feb 15 '15 at 1:25
1
Yes, we definitely do :)
– Julian Hernandez
Feb 15 '15 at 6:59
add a comment |
1
Hi Julian, thanks for this. I actually do use a star.sh script to to kill and run the containers (the application is stateless, so that's not a problem in terms of data). But this is some kind of dirty. Do you know if there is a way to run this line inside the container automatically upon every restart?
– Steven
Feb 13 '15 at 17:52
Well... actually that's what I intend to do with that line. My applications are stateless too, so every time a container starts, this RUNNING_PID file gets removed and a new one with a different identifier gets created. I know it's not the most elegant thing in the world though. I don't know as of now of any other way of accomplishing the same in a more natural way using docker.
– Julian Hernandez
Feb 14 '15 at 22:33
But we agree on the fact that this is not a misbehaviour of Docker but of Play, right?
– Steven
Feb 15 '15 at 1:25
1
Yes, we definitely do :)
– Julian Hernandez
Feb 15 '15 at 6:59
1
1
Hi Julian, thanks for this. I actually do use a star.sh script to to kill and run the containers (the application is stateless, so that's not a problem in terms of data). But this is some kind of dirty. Do you know if there is a way to run this line inside the container automatically upon every restart?
– Steven
Feb 13 '15 at 17:52
Hi Julian, thanks for this. I actually do use a star.sh script to to kill and run the containers (the application is stateless, so that's not a problem in terms of data). But this is some kind of dirty. Do you know if there is a way to run this line inside the container automatically upon every restart?
– Steven
Feb 13 '15 at 17:52
Well... actually that's what I intend to do with that line. My applications are stateless too, so every time a container starts, this RUNNING_PID file gets removed and a new one with a different identifier gets created. I know it's not the most elegant thing in the world though. I don't know as of now of any other way of accomplishing the same in a more natural way using docker.
– Julian Hernandez
Feb 14 '15 at 22:33
Well... actually that's what I intend to do with that line. My applications are stateless too, so every time a container starts, this RUNNING_PID file gets removed and a new one with a different identifier gets created. I know it's not the most elegant thing in the world though. I don't know as of now of any other way of accomplishing the same in a more natural way using docker.
– Julian Hernandez
Feb 14 '15 at 22:33
But we agree on the fact that this is not a misbehaviour of Docker but of Play, right?
– Steven
Feb 15 '15 at 1:25
But we agree on the fact that this is not a misbehaviour of Docker but of Play, right?
– Steven
Feb 15 '15 at 1:25
1
1
Yes, we definitely do :)
– Julian Hernandez
Feb 15 '15 at 6:59
Yes, we definitely do :)
– Julian Hernandez
Feb 15 '15 at 6:59
add a comment |
I don't know much about docker, but Play does not remove RUNNING_PID
on stopping the server as far as I have tested. When I deployed my app in prod
mode and try to stop it by Ctrl+D
and Ctrl+C
it din't remove the RUNNING_PID file from project directory so I had to manually delete it. From Play docs
Normally this(RUNNING_PID) file is placed in the root directory of your play
project, however it is advised that you put it somewhere where it will
be automatically cleared on restart, such as/var/run
:
So - apart from manual deletion - the workaround is to change the path of RUNNING_PID and delete it every time the server starts through some script.
$ /path/to/bin/<project-name> -Dpidfile.path=/var/run/play.pid
Make sure that the directory exists and that the user that runs the Play application has write permission for it.
Using this file, you can stop your application using the kill command, for example:
$ kill $(cat /var/run/play.pid)
and you can also try docker command $ sudo docker rm --force redis
Maybe That could help
Source1 Source2 Source3
Hello singhakash, thank you for your answer. I already developed a workaround by an external script which kills the container on restart and restarts it. But this is not satisfying for me. Also, as you can see in my question, I already changed the location of the RUNNING_PID file. As I pointed out in my expectations I would like to have a restarting Docker container, not to kill it and then run it again. It is part of a larger infrastructure and other components rely on its presence.
– Steven
Feb 11 '15 at 10:13
add a comment |
I don't know much about docker, but Play does not remove RUNNING_PID
on stopping the server as far as I have tested. When I deployed my app in prod
mode and try to stop it by Ctrl+D
and Ctrl+C
it din't remove the RUNNING_PID file from project directory so I had to manually delete it. From Play docs
Normally this(RUNNING_PID) file is placed in the root directory of your play
project, however it is advised that you put it somewhere where it will
be automatically cleared on restart, such as/var/run
:
So - apart from manual deletion - the workaround is to change the path of RUNNING_PID and delete it every time the server starts through some script.
$ /path/to/bin/<project-name> -Dpidfile.path=/var/run/play.pid
Make sure that the directory exists and that the user that runs the Play application has write permission for it.
Using this file, you can stop your application using the kill command, for example:
$ kill $(cat /var/run/play.pid)
and you can also try docker command $ sudo docker rm --force redis
Maybe That could help
Source1 Source2 Source3
Hello singhakash, thank you for your answer. I already developed a workaround by an external script which kills the container on restart and restarts it. But this is not satisfying for me. Also, as you can see in my question, I already changed the location of the RUNNING_PID file. As I pointed out in my expectations I would like to have a restarting Docker container, not to kill it and then run it again. It is part of a larger infrastructure and other components rely on its presence.
– Steven
Feb 11 '15 at 10:13
add a comment |
I don't know much about docker, but Play does not remove RUNNING_PID
on stopping the server as far as I have tested. When I deployed my app in prod
mode and try to stop it by Ctrl+D
and Ctrl+C
it din't remove the RUNNING_PID file from project directory so I had to manually delete it. From Play docs
Normally this(RUNNING_PID) file is placed in the root directory of your play
project, however it is advised that you put it somewhere where it will
be automatically cleared on restart, such as/var/run
:
So - apart from manual deletion - the workaround is to change the path of RUNNING_PID and delete it every time the server starts through some script.
$ /path/to/bin/<project-name> -Dpidfile.path=/var/run/play.pid
Make sure that the directory exists and that the user that runs the Play application has write permission for it.
Using this file, you can stop your application using the kill command, for example:
$ kill $(cat /var/run/play.pid)
and you can also try docker command $ sudo docker rm --force redis
Maybe That could help
Source1 Source2 Source3
I don't know much about docker, but Play does not remove RUNNING_PID
on stopping the server as far as I have tested. When I deployed my app in prod
mode and try to stop it by Ctrl+D
and Ctrl+C
it din't remove the RUNNING_PID file from project directory so I had to manually delete it. From Play docs
Normally this(RUNNING_PID) file is placed in the root directory of your play
project, however it is advised that you put it somewhere where it will
be automatically cleared on restart, such as/var/run
:
So - apart from manual deletion - the workaround is to change the path of RUNNING_PID and delete it every time the server starts through some script.
$ /path/to/bin/<project-name> -Dpidfile.path=/var/run/play.pid
Make sure that the directory exists and that the user that runs the Play application has write permission for it.
Using this file, you can stop your application using the kill command, for example:
$ kill $(cat /var/run/play.pid)
and you can also try docker command $ sudo docker rm --force redis
Maybe That could help
Source1 Source2 Source3
edited Mar 8 at 19:08
Nathaniel Ford
13.7k155675
13.7k155675
answered Feb 11 '15 at 7:58
singhakashsinghakash
6,59332048
6,59332048
Hello singhakash, thank you for your answer. I already developed a workaround by an external script which kills the container on restart and restarts it. But this is not satisfying for me. Also, as you can see in my question, I already changed the location of the RUNNING_PID file. As I pointed out in my expectations I would like to have a restarting Docker container, not to kill it and then run it again. It is part of a larger infrastructure and other components rely on its presence.
– Steven
Feb 11 '15 at 10:13
add a comment |
Hello singhakash, thank you for your answer. I already developed a workaround by an external script which kills the container on restart and restarts it. But this is not satisfying for me. Also, as you can see in my question, I already changed the location of the RUNNING_PID file. As I pointed out in my expectations I would like to have a restarting Docker container, not to kill it and then run it again. It is part of a larger infrastructure and other components rely on its presence.
– Steven
Feb 11 '15 at 10:13
Hello singhakash, thank you for your answer. I already developed a workaround by an external script which kills the container on restart and restarts it. But this is not satisfying for me. Also, as you can see in my question, I already changed the location of the RUNNING_PID file. As I pointed out in my expectations I would like to have a restarting Docker container, not to kill it and then run it again. It is part of a larger infrastructure and other components rely on its presence.
– Steven
Feb 11 '15 at 10:13
Hello singhakash, thank you for your answer. I already developed a workaround by an external script which kills the container on restart and restarts it. But this is not satisfying for me. Also, as you can see in my question, I already changed the location of the RUNNING_PID file. As I pointed out in my expectations I would like to have a restarting Docker container, not to kill it and then run it again. It is part of a larger infrastructure and other components rely on its presence.
– Steven
Feb 11 '15 at 10:13
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f28351405%2frestarting-play-application-docker-container-results-in-this-application-is-alr%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown