Starting service only if its not already up - docker-compose
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I have a docker-compose file that controls a few services.
One of which are a db service. I don't always want to restart the db service.
Example docker-compose.yml:
version: '3'
services:
base:
commad: "echo somecommand"
postgres:
container_name: postgres
image: "postgres:latest"
environment:
- POSTGRES_PASSWORD=usr
- POSTGRES_USER=use
- POSTGRES_DB=usr
ports:
- 5432:5432
How can I do docker-compose up, but if the db service (postgres in my case) is already up, making sure it wont restart.
Im currently using docker-compose down/up, and my db restarts.
I tried to add --scale postgres=0 to my docker-compose up command, but then it shuts down postgres all together.
docker docker-compose
add a comment |
I have a docker-compose file that controls a few services.
One of which are a db service. I don't always want to restart the db service.
Example docker-compose.yml:
version: '3'
services:
base:
commad: "echo somecommand"
postgres:
container_name: postgres
image: "postgres:latest"
environment:
- POSTGRES_PASSWORD=usr
- POSTGRES_USER=use
- POSTGRES_DB=usr
ports:
- 5432:5432
How can I do docker-compose up, but if the db service (postgres in my case) is already up, making sure it wont restart.
Im currently using docker-compose down/up, and my db restarts.
I tried to add --scale postgres=0 to my docker-compose up command, but then it shuts down postgres all together.
docker docker-compose
add a comment |
I have a docker-compose file that controls a few services.
One of which are a db service. I don't always want to restart the db service.
Example docker-compose.yml:
version: '3'
services:
base:
commad: "echo somecommand"
postgres:
container_name: postgres
image: "postgres:latest"
environment:
- POSTGRES_PASSWORD=usr
- POSTGRES_USER=use
- POSTGRES_DB=usr
ports:
- 5432:5432
How can I do docker-compose up, but if the db service (postgres in my case) is already up, making sure it wont restart.
Im currently using docker-compose down/up, and my db restarts.
I tried to add --scale postgres=0 to my docker-compose up command, but then it shuts down postgres all together.
docker docker-compose
I have a docker-compose file that controls a few services.
One of which are a db service. I don't always want to restart the db service.
Example docker-compose.yml:
version: '3'
services:
base:
commad: "echo somecommand"
postgres:
container_name: postgres
image: "postgres:latest"
environment:
- POSTGRES_PASSWORD=usr
- POSTGRES_USER=use
- POSTGRES_DB=usr
ports:
- 5432:5432
How can I do docker-compose up, but if the db service (postgres in my case) is already up, making sure it wont restart.
Im currently using docker-compose down/up, and my db restarts.
I tried to add --scale postgres=0 to my docker-compose up command, but then it shuts down postgres all together.
docker docker-compose
docker docker-compose
edited Nov 26 '18 at 17:59
Roman Konoval
8,39412334
8,39412334
asked Nov 26 '18 at 16:49
NotSoShabbyNotSoShabby
344517
344517
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Use docker-compose up --no-recreate.
Ref https://docs.docker.com/compose/reference/up/
but I do want to recreate base service. Is there a way to specify which container I dont want to recreate? or specify for docker-compose down, specific services to kill/remove?
– NotSoShabby
Nov 26 '18 at 17:30
docker-compose up service_name? this way you control which service to run.
– Siyu
Nov 26 '18 at 17:33
Butdocker-compose down service_nameis not bringing down the service
– NotSoShabby
Nov 26 '18 at 17:37
2
@NotSoShabby no you need ‘docker-compose rm -s service’ instead
– Siyu
Nov 26 '18 at 18:03
add a comment |
Your Answer
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%2f53485628%2fstarting-service-only-if-its-not-already-up-docker-compose%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use docker-compose up --no-recreate.
Ref https://docs.docker.com/compose/reference/up/
but I do want to recreate base service. Is there a way to specify which container I dont want to recreate? or specify for docker-compose down, specific services to kill/remove?
– NotSoShabby
Nov 26 '18 at 17:30
docker-compose up service_name? this way you control which service to run.
– Siyu
Nov 26 '18 at 17:33
Butdocker-compose down service_nameis not bringing down the service
– NotSoShabby
Nov 26 '18 at 17:37
2
@NotSoShabby no you need ‘docker-compose rm -s service’ instead
– Siyu
Nov 26 '18 at 18:03
add a comment |
Use docker-compose up --no-recreate.
Ref https://docs.docker.com/compose/reference/up/
but I do want to recreate base service. Is there a way to specify which container I dont want to recreate? or specify for docker-compose down, specific services to kill/remove?
– NotSoShabby
Nov 26 '18 at 17:30
docker-compose up service_name? this way you control which service to run.
– Siyu
Nov 26 '18 at 17:33
Butdocker-compose down service_nameis not bringing down the service
– NotSoShabby
Nov 26 '18 at 17:37
2
@NotSoShabby no you need ‘docker-compose rm -s service’ instead
– Siyu
Nov 26 '18 at 18:03
add a comment |
Use docker-compose up --no-recreate.
Ref https://docs.docker.com/compose/reference/up/
Use docker-compose up --no-recreate.
Ref https://docs.docker.com/compose/reference/up/
answered Nov 26 '18 at 17:23
SiyuSiyu
3,25211231
3,25211231
but I do want to recreate base service. Is there a way to specify which container I dont want to recreate? or specify for docker-compose down, specific services to kill/remove?
– NotSoShabby
Nov 26 '18 at 17:30
docker-compose up service_name? this way you control which service to run.
– Siyu
Nov 26 '18 at 17:33
Butdocker-compose down service_nameis not bringing down the service
– NotSoShabby
Nov 26 '18 at 17:37
2
@NotSoShabby no you need ‘docker-compose rm -s service’ instead
– Siyu
Nov 26 '18 at 18:03
add a comment |
but I do want to recreate base service. Is there a way to specify which container I dont want to recreate? or specify for docker-compose down, specific services to kill/remove?
– NotSoShabby
Nov 26 '18 at 17:30
docker-compose up service_name? this way you control which service to run.
– Siyu
Nov 26 '18 at 17:33
Butdocker-compose down service_nameis not bringing down the service
– NotSoShabby
Nov 26 '18 at 17:37
2
@NotSoShabby no you need ‘docker-compose rm -s service’ instead
– Siyu
Nov 26 '18 at 18:03
but I do want to recreate base service. Is there a way to specify which container I dont want to recreate? or specify for docker-compose down, specific services to kill/remove?
– NotSoShabby
Nov 26 '18 at 17:30
but I do want to recreate base service. Is there a way to specify which container I dont want to recreate? or specify for docker-compose down, specific services to kill/remove?
– NotSoShabby
Nov 26 '18 at 17:30
docker-compose up service_name? this way you control which service to run.– Siyu
Nov 26 '18 at 17:33
docker-compose up service_name? this way you control which service to run.– Siyu
Nov 26 '18 at 17:33
But
docker-compose down service_name is not bringing down the service– NotSoShabby
Nov 26 '18 at 17:37
But
docker-compose down service_name is not bringing down the service– NotSoShabby
Nov 26 '18 at 17:37
2
2
@NotSoShabby no you need ‘docker-compose rm -s service’ instead
– Siyu
Nov 26 '18 at 18:03
@NotSoShabby no you need ‘docker-compose rm -s service’ instead
– Siyu
Nov 26 '18 at 18:03
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%2f53485628%2fstarting-service-only-if-its-not-already-up-docker-compose%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