How to run container in background while using docker compose
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I used docker-compose up -d .
but my docker container exits after executing my script. This is my below docker-compose.yml file. I want to run docker container in the background.
version: "3"
services:
master:
build: .
command: sh /opt/spark/sbin/start-master.sh
ports:
- 8080:8080
- 8081:8081
- 7077:7077
- 4040:4040
worker:
depends_on:
- master
deploy:
- replicas: 2
- endpoint_mode: dnsrr
build: .
command: sh /opt/spark/sbin/start-slave.sh spark://172.17.0.2:7077
ports:
- 9080:8080
- 9081:8081
- 9077:7077
- 9040:4040
================
$ docker container ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
975a3af7dc27 mysparkdocker_master "sh /opt/spark/sbin/…" 41 minutes ago Exited (0) 18 seconds ago mysparkdocker_master_1
e52cf60c820c mysparkdocker_worker "sh /opt/spark/sbin/…" 41 minutes ago Exited (0) 17 seconds ago mysparkdocker_worker_1
===================================
docker background compose
add a comment |
I used docker-compose up -d .
but my docker container exits after executing my script. This is my below docker-compose.yml file. I want to run docker container in the background.
version: "3"
services:
master:
build: .
command: sh /opt/spark/sbin/start-master.sh
ports:
- 8080:8080
- 8081:8081
- 7077:7077
- 4040:4040
worker:
depends_on:
- master
deploy:
- replicas: 2
- endpoint_mode: dnsrr
build: .
command: sh /opt/spark/sbin/start-slave.sh spark://172.17.0.2:7077
ports:
- 9080:8080
- 9081:8081
- 9077:7077
- 9040:4040
================
$ docker container ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
975a3af7dc27 mysparkdocker_master "sh /opt/spark/sbin/…" 41 minutes ago Exited (0) 18 seconds ago mysparkdocker_master_1
e52cf60c820c mysparkdocker_worker "sh /opt/spark/sbin/…" 41 minutes ago Exited (0) 17 seconds ago mysparkdocker_worker_1
===================================
docker background compose
1
Possible duplicate of How to keep Docker container running after starting services?
– David Maze
Nov 16 '18 at 12:59
add a comment |
I used docker-compose up -d .
but my docker container exits after executing my script. This is my below docker-compose.yml file. I want to run docker container in the background.
version: "3"
services:
master:
build: .
command: sh /opt/spark/sbin/start-master.sh
ports:
- 8080:8080
- 8081:8081
- 7077:7077
- 4040:4040
worker:
depends_on:
- master
deploy:
- replicas: 2
- endpoint_mode: dnsrr
build: .
command: sh /opt/spark/sbin/start-slave.sh spark://172.17.0.2:7077
ports:
- 9080:8080
- 9081:8081
- 9077:7077
- 9040:4040
================
$ docker container ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
975a3af7dc27 mysparkdocker_master "sh /opt/spark/sbin/…" 41 minutes ago Exited (0) 18 seconds ago mysparkdocker_master_1
e52cf60c820c mysparkdocker_worker "sh /opt/spark/sbin/…" 41 minutes ago Exited (0) 17 seconds ago mysparkdocker_worker_1
===================================
docker background compose
I used docker-compose up -d .
but my docker container exits after executing my script. This is my below docker-compose.yml file. I want to run docker container in the background.
version: "3"
services:
master:
build: .
command: sh /opt/spark/sbin/start-master.sh
ports:
- 8080:8080
- 8081:8081
- 7077:7077
- 4040:4040
worker:
depends_on:
- master
deploy:
- replicas: 2
- endpoint_mode: dnsrr
build: .
command: sh /opt/spark/sbin/start-slave.sh spark://172.17.0.2:7077
ports:
- 9080:8080
- 9081:8081
- 9077:7077
- 9040:4040
================
$ docker container ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
975a3af7dc27 mysparkdocker_master "sh /opt/spark/sbin/…" 41 minutes ago Exited (0) 18 seconds ago mysparkdocker_master_1
e52cf60c820c mysparkdocker_worker "sh /opt/spark/sbin/…" 41 minutes ago Exited (0) 17 seconds ago mysparkdocker_worker_1
===================================
docker background compose
docker background compose
asked Nov 16 '18 at 11:51
Sakthivel GSakthivel G
235
235
1
Possible duplicate of How to keep Docker container running after starting services?
– David Maze
Nov 16 '18 at 12:59
add a comment |
1
Possible duplicate of How to keep Docker container running after starting services?
– David Maze
Nov 16 '18 at 12:59
1
1
Possible duplicate of How to keep Docker container running after starting services?
– David Maze
Nov 16 '18 at 12:59
Possible duplicate of How to keep Docker container running after starting services?
– David Maze
Nov 16 '18 at 12:59
add a comment |
1 Answer
1
active
oldest
votes
The problem is that your shell scripts probably fork themselves to create a daemon, whereas in the Docker model, you would actually not want them to daemonize themselves, because the process would exit and thereby stop the container.
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%2f53337339%2fhow-to-run-container-in-background-while-using-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
The problem is that your shell scripts probably fork themselves to create a daemon, whereas in the Docker model, you would actually not want them to daemonize themselves, because the process would exit and thereby stop the container.
add a comment |
The problem is that your shell scripts probably fork themselves to create a daemon, whereas in the Docker model, you would actually not want them to daemonize themselves, because the process would exit and thereby stop the container.
add a comment |
The problem is that your shell scripts probably fork themselves to create a daemon, whereas in the Docker model, you would actually not want them to daemonize themselves, because the process would exit and thereby stop the container.
The problem is that your shell scripts probably fork themselves to create a daemon, whereas in the Docker model, you would actually not want them to daemonize themselves, because the process would exit and thereby stop the container.
answered Nov 16 '18 at 12:28
Uku LoskitUku Loskit
31.1k87081
31.1k87081
add a comment |
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%2f53337339%2fhow-to-run-container-in-background-while-using-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
1
Possible duplicate of How to keep Docker container running after starting services?
– David Maze
Nov 16 '18 at 12:59