Google compute engine instance created with container executes multiple times instead of a single time





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















There has been an issue with Google compute instances created with containers running the startup script up to 10-20 times.



Case 1:
The container is built through Docker, then pushed to the online registry, and then an instance is created with that container. The startup script "Test.py" is instantiated through the container creation instead of being built into the Docker File directly. The following command is used to create an instance with a container and arguments:



gcloud compute instances create-with-container busybox-vm --container-image gcr.io/example-project-id/ttime2 --container-command python --container-arg="/Test.py" --container-arg="Args"


Case 2:
Including the startup script (Test.py) and corresponding arguments within the docker image itself, and then instantiating an instance also resulted in multiple runs of the script.



Notes:




  1. The startup script is ran as a sub-process so the standard output can be easily sent to a remote server where it can be monitored for debugging purposes.


  2. The startup script is executed multiple times before the first execution is finished (as the end of the script kills the instance successfully).


  3. When running this docker build locally, it performs as expected with just one code execution.


  4. I've experienced this multiple startup script execution on several different docker images


  5. Only one instance is created.



A solution it seems would be to check for subprocesses as they spawn and kill any duplicates, I'm just not sure how I'd identify them.



Edit:If you have some general tips on tackling problems with containers that have "crashlooping" I'd like to accept that as an answer. I was personally able to add the following flag --container-restart-policy="never" to the above gcloud command to get a large variety of tests to work (not sure why), so I'm done with this issue for now.










share|improve this question

























  • When you say startup script, are you referring to test.py or the VM startup script?

    – Vincent
    Nov 24 '18 at 22:14











  • I will make an edit to clarify, thanks. Startup script only refers to test.py, in Case 2 it's included in the Docker File.

    – The Highlight Hub
    Nov 24 '18 at 22:17




















0















There has been an issue with Google compute instances created with containers running the startup script up to 10-20 times.



Case 1:
The container is built through Docker, then pushed to the online registry, and then an instance is created with that container. The startup script "Test.py" is instantiated through the container creation instead of being built into the Docker File directly. The following command is used to create an instance with a container and arguments:



gcloud compute instances create-with-container busybox-vm --container-image gcr.io/example-project-id/ttime2 --container-command python --container-arg="/Test.py" --container-arg="Args"


Case 2:
Including the startup script (Test.py) and corresponding arguments within the docker image itself, and then instantiating an instance also resulted in multiple runs of the script.



Notes:




  1. The startup script is ran as a sub-process so the standard output can be easily sent to a remote server where it can be monitored for debugging purposes.


  2. The startup script is executed multiple times before the first execution is finished (as the end of the script kills the instance successfully).


  3. When running this docker build locally, it performs as expected with just one code execution.


  4. I've experienced this multiple startup script execution on several different docker images


  5. Only one instance is created.



A solution it seems would be to check for subprocesses as they spawn and kill any duplicates, I'm just not sure how I'd identify them.



Edit:If you have some general tips on tackling problems with containers that have "crashlooping" I'd like to accept that as an answer. I was personally able to add the following flag --container-restart-policy="never" to the above gcloud command to get a large variety of tests to work (not sure why), so I'm done with this issue for now.










share|improve this question

























  • When you say startup script, are you referring to test.py or the VM startup script?

    – Vincent
    Nov 24 '18 at 22:14











  • I will make an edit to clarify, thanks. Startup script only refers to test.py, in Case 2 it's included in the Docker File.

    – The Highlight Hub
    Nov 24 '18 at 22:17
















0












0








0








There has been an issue with Google compute instances created with containers running the startup script up to 10-20 times.



Case 1:
The container is built through Docker, then pushed to the online registry, and then an instance is created with that container. The startup script "Test.py" is instantiated through the container creation instead of being built into the Docker File directly. The following command is used to create an instance with a container and arguments:



gcloud compute instances create-with-container busybox-vm --container-image gcr.io/example-project-id/ttime2 --container-command python --container-arg="/Test.py" --container-arg="Args"


Case 2:
Including the startup script (Test.py) and corresponding arguments within the docker image itself, and then instantiating an instance also resulted in multiple runs of the script.



Notes:




  1. The startup script is ran as a sub-process so the standard output can be easily sent to a remote server where it can be monitored for debugging purposes.


  2. The startup script is executed multiple times before the first execution is finished (as the end of the script kills the instance successfully).


  3. When running this docker build locally, it performs as expected with just one code execution.


  4. I've experienced this multiple startup script execution on several different docker images


  5. Only one instance is created.



A solution it seems would be to check for subprocesses as they spawn and kill any duplicates, I'm just not sure how I'd identify them.



Edit:If you have some general tips on tackling problems with containers that have "crashlooping" I'd like to accept that as an answer. I was personally able to add the following flag --container-restart-policy="never" to the above gcloud command to get a large variety of tests to work (not sure why), so I'm done with this issue for now.










share|improve this question
















There has been an issue with Google compute instances created with containers running the startup script up to 10-20 times.



Case 1:
The container is built through Docker, then pushed to the online registry, and then an instance is created with that container. The startup script "Test.py" is instantiated through the container creation instead of being built into the Docker File directly. The following command is used to create an instance with a container and arguments:



gcloud compute instances create-with-container busybox-vm --container-image gcr.io/example-project-id/ttime2 --container-command python --container-arg="/Test.py" --container-arg="Args"


Case 2:
Including the startup script (Test.py) and corresponding arguments within the docker image itself, and then instantiating an instance also resulted in multiple runs of the script.



Notes:




  1. The startup script is ran as a sub-process so the standard output can be easily sent to a remote server where it can be monitored for debugging purposes.


  2. The startup script is executed multiple times before the first execution is finished (as the end of the script kills the instance successfully).


  3. When running this docker build locally, it performs as expected with just one code execution.


  4. I've experienced this multiple startup script execution on several different docker images


  5. Only one instance is created.



A solution it seems would be to check for subprocesses as they spawn and kill any duplicates, I'm just not sure how I'd identify them.



Edit:If you have some general tips on tackling problems with containers that have "crashlooping" I'd like to accept that as an answer. I was personally able to add the following flag --container-restart-policy="never" to the above gcloud command to get a large variety of tests to work (not sure why), so I'm done with this issue for now.







containers google-compute-engine gcloud






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 1 '18 at 6:45







The Highlight Hub

















asked Nov 24 '18 at 20:50









The Highlight HubThe Highlight Hub

11




11













  • When you say startup script, are you referring to test.py or the VM startup script?

    – Vincent
    Nov 24 '18 at 22:14











  • I will make an edit to clarify, thanks. Startup script only refers to test.py, in Case 2 it's included in the Docker File.

    – The Highlight Hub
    Nov 24 '18 at 22:17





















  • When you say startup script, are you referring to test.py or the VM startup script?

    – Vincent
    Nov 24 '18 at 22:14











  • I will make an edit to clarify, thanks. Startup script only refers to test.py, in Case 2 it's included in the Docker File.

    – The Highlight Hub
    Nov 24 '18 at 22:17



















When you say startup script, are you referring to test.py or the VM startup script?

– Vincent
Nov 24 '18 at 22:14





When you say startup script, are you referring to test.py or the VM startup script?

– Vincent
Nov 24 '18 at 22:14













I will make an edit to clarify, thanks. Startup script only refers to test.py, in Case 2 it's included in the Docker File.

– The Highlight Hub
Nov 24 '18 at 22:17







I will make an edit to clarify, thanks. Startup script only refers to test.py, in Case 2 it's included in the Docker File.

– The Highlight Hub
Nov 24 '18 at 22:17














1 Answer
1






active

oldest

votes


















0














This could be one of many reasons. A good way to diagnose would be to:




  1. change to --container-command "sleep 50000" and create a vm.

  2. ssh into the vm and run sudo -i

  3. run docker ps -a until you see a container of yours appear.

  4. get its container id and docker exec -it <ID> bash(change to sh if necessary). Your container should be sleeping. This will let you go into your container.

  5. execute Test.py from within your container to see if there's an error.


This requires your image to have sleep.






share|improve this answer
























  • An update - Following your instructions, I was able to run the startup script, with successful code execution, except having to enter y/n to standard input when asked to overwrite a file.

    – The Highlight Hub
    Nov 25 '18 at 2:36











  • @TheHighlightHub overwrite a file? I don’t know enough about your code to help further. Hopefully this helped.

    – Vincent
    Nov 25 '18 at 3:04











  • I just meant to emphasize the standard input part as it's not expected behavior (doesn't occur on a locally run docker instance), hence my code doesn't explicitly enter anything, yet multiple code completions are observed. I appreciate the information about accessing the instance via ssh, I'll read more into some tools that'll help debug this thing.

    – The Highlight Hub
    Nov 25 '18 at 3:29














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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53462253%2fgoogle-compute-engine-instance-created-with-container-executes-multiple-times-in%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









0














This could be one of many reasons. A good way to diagnose would be to:




  1. change to --container-command "sleep 50000" and create a vm.

  2. ssh into the vm and run sudo -i

  3. run docker ps -a until you see a container of yours appear.

  4. get its container id and docker exec -it <ID> bash(change to sh if necessary). Your container should be sleeping. This will let you go into your container.

  5. execute Test.py from within your container to see if there's an error.


This requires your image to have sleep.






share|improve this answer
























  • An update - Following your instructions, I was able to run the startup script, with successful code execution, except having to enter y/n to standard input when asked to overwrite a file.

    – The Highlight Hub
    Nov 25 '18 at 2:36











  • @TheHighlightHub overwrite a file? I don’t know enough about your code to help further. Hopefully this helped.

    – Vincent
    Nov 25 '18 at 3:04











  • I just meant to emphasize the standard input part as it's not expected behavior (doesn't occur on a locally run docker instance), hence my code doesn't explicitly enter anything, yet multiple code completions are observed. I appreciate the information about accessing the instance via ssh, I'll read more into some tools that'll help debug this thing.

    – The Highlight Hub
    Nov 25 '18 at 3:29


















0














This could be one of many reasons. A good way to diagnose would be to:




  1. change to --container-command "sleep 50000" and create a vm.

  2. ssh into the vm and run sudo -i

  3. run docker ps -a until you see a container of yours appear.

  4. get its container id and docker exec -it <ID> bash(change to sh if necessary). Your container should be sleeping. This will let you go into your container.

  5. execute Test.py from within your container to see if there's an error.


This requires your image to have sleep.






share|improve this answer
























  • An update - Following your instructions, I was able to run the startup script, with successful code execution, except having to enter y/n to standard input when asked to overwrite a file.

    – The Highlight Hub
    Nov 25 '18 at 2:36











  • @TheHighlightHub overwrite a file? I don’t know enough about your code to help further. Hopefully this helped.

    – Vincent
    Nov 25 '18 at 3:04











  • I just meant to emphasize the standard input part as it's not expected behavior (doesn't occur on a locally run docker instance), hence my code doesn't explicitly enter anything, yet multiple code completions are observed. I appreciate the information about accessing the instance via ssh, I'll read more into some tools that'll help debug this thing.

    – The Highlight Hub
    Nov 25 '18 at 3:29
















0












0








0







This could be one of many reasons. A good way to diagnose would be to:




  1. change to --container-command "sleep 50000" and create a vm.

  2. ssh into the vm and run sudo -i

  3. run docker ps -a until you see a container of yours appear.

  4. get its container id and docker exec -it <ID> bash(change to sh if necessary). Your container should be sleeping. This will let you go into your container.

  5. execute Test.py from within your container to see if there's an error.


This requires your image to have sleep.






share|improve this answer













This could be one of many reasons. A good way to diagnose would be to:




  1. change to --container-command "sleep 50000" and create a vm.

  2. ssh into the vm and run sudo -i

  3. run docker ps -a until you see a container of yours appear.

  4. get its container id and docker exec -it <ID> bash(change to sh if necessary). Your container should be sleeping. This will let you go into your container.

  5. execute Test.py from within your container to see if there's an error.


This requires your image to have sleep.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 24 '18 at 22:55









VincentVincent

7781216




7781216













  • An update - Following your instructions, I was able to run the startup script, with successful code execution, except having to enter y/n to standard input when asked to overwrite a file.

    – The Highlight Hub
    Nov 25 '18 at 2:36











  • @TheHighlightHub overwrite a file? I don’t know enough about your code to help further. Hopefully this helped.

    – Vincent
    Nov 25 '18 at 3:04











  • I just meant to emphasize the standard input part as it's not expected behavior (doesn't occur on a locally run docker instance), hence my code doesn't explicitly enter anything, yet multiple code completions are observed. I appreciate the information about accessing the instance via ssh, I'll read more into some tools that'll help debug this thing.

    – The Highlight Hub
    Nov 25 '18 at 3:29





















  • An update - Following your instructions, I was able to run the startup script, with successful code execution, except having to enter y/n to standard input when asked to overwrite a file.

    – The Highlight Hub
    Nov 25 '18 at 2:36











  • @TheHighlightHub overwrite a file? I don’t know enough about your code to help further. Hopefully this helped.

    – Vincent
    Nov 25 '18 at 3:04











  • I just meant to emphasize the standard input part as it's not expected behavior (doesn't occur on a locally run docker instance), hence my code doesn't explicitly enter anything, yet multiple code completions are observed. I appreciate the information about accessing the instance via ssh, I'll read more into some tools that'll help debug this thing.

    – The Highlight Hub
    Nov 25 '18 at 3:29



















An update - Following your instructions, I was able to run the startup script, with successful code execution, except having to enter y/n to standard input when asked to overwrite a file.

– The Highlight Hub
Nov 25 '18 at 2:36





An update - Following your instructions, I was able to run the startup script, with successful code execution, except having to enter y/n to standard input when asked to overwrite a file.

– The Highlight Hub
Nov 25 '18 at 2:36













@TheHighlightHub overwrite a file? I don’t know enough about your code to help further. Hopefully this helped.

– Vincent
Nov 25 '18 at 3:04





@TheHighlightHub overwrite a file? I don’t know enough about your code to help further. Hopefully this helped.

– Vincent
Nov 25 '18 at 3:04













I just meant to emphasize the standard input part as it's not expected behavior (doesn't occur on a locally run docker instance), hence my code doesn't explicitly enter anything, yet multiple code completions are observed. I appreciate the information about accessing the instance via ssh, I'll read more into some tools that'll help debug this thing.

– The Highlight Hub
Nov 25 '18 at 3:29







I just meant to emphasize the standard input part as it's not expected behavior (doesn't occur on a locally run docker instance), hence my code doesn't explicitly enter anything, yet multiple code completions are observed. I appreciate the information about accessing the instance via ssh, I'll read more into some tools that'll help debug this thing.

– The Highlight Hub
Nov 25 '18 at 3:29






















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53462253%2fgoogle-compute-engine-instance-created-with-container-executes-multiple-times-in%23new-answer', 'question_page');
}
);

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







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini