container keep exiting right after running it












1














docker-compose.yaml:



web:
build: .
command: ./main
ports:
- "8888:3412"
volumes:
- .:/code
links:
- redis
redis:
image: redis


Dockerfile:



FROM golang:1.6
ADD main.go .
EXPOSE 3412
ENTRYPOINT /go
RUN go build main.go


so after running docker run -d imagename, there is no running container



also docker logs containername doesn't show anything










share|improve this question






















  • Could you include the rest of the code as well? The Go code, and how you build imagename?
    – Harald Nordgren
    Nov 18 '18 at 20:48










  • @HaraldNordgren the code worked fine (tried docker run -it and ran main manually which worked). it would log error if it couldnt build right ?
    – danicheeta
    Nov 18 '18 at 20:54










  • I didn't say there was anything wrong the rest of the code. But it helps us reproduce your exact problem to potentially help you fix it.
    – Harald Nordgren
    Nov 18 '18 at 21:05
















1














docker-compose.yaml:



web:
build: .
command: ./main
ports:
- "8888:3412"
volumes:
- .:/code
links:
- redis
redis:
image: redis


Dockerfile:



FROM golang:1.6
ADD main.go .
EXPOSE 3412
ENTRYPOINT /go
RUN go build main.go


so after running docker run -d imagename, there is no running container



also docker logs containername doesn't show anything










share|improve this question






















  • Could you include the rest of the code as well? The Go code, and how you build imagename?
    – Harald Nordgren
    Nov 18 '18 at 20:48










  • @HaraldNordgren the code worked fine (tried docker run -it and ran main manually which worked). it would log error if it couldnt build right ?
    – danicheeta
    Nov 18 '18 at 20:54










  • I didn't say there was anything wrong the rest of the code. But it helps us reproduce your exact problem to potentially help you fix it.
    – Harald Nordgren
    Nov 18 '18 at 21:05














1












1








1







docker-compose.yaml:



web:
build: .
command: ./main
ports:
- "8888:3412"
volumes:
- .:/code
links:
- redis
redis:
image: redis


Dockerfile:



FROM golang:1.6
ADD main.go .
EXPOSE 3412
ENTRYPOINT /go
RUN go build main.go


so after running docker run -d imagename, there is no running container



also docker logs containername doesn't show anything










share|improve this question













docker-compose.yaml:



web:
build: .
command: ./main
ports:
- "8888:3412"
volumes:
- .:/code
links:
- redis
redis:
image: redis


Dockerfile:



FROM golang:1.6
ADD main.go .
EXPOSE 3412
ENTRYPOINT /go
RUN go build main.go


so after running docker run -d imagename, there is no running container



also docker logs containername doesn't show anything







docker docker-compose






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 18 '18 at 20:18









danicheetadanicheeta

1,004517




1,004517












  • Could you include the rest of the code as well? The Go code, and how you build imagename?
    – Harald Nordgren
    Nov 18 '18 at 20:48










  • @HaraldNordgren the code worked fine (tried docker run -it and ran main manually which worked). it would log error if it couldnt build right ?
    – danicheeta
    Nov 18 '18 at 20:54










  • I didn't say there was anything wrong the rest of the code. But it helps us reproduce your exact problem to potentially help you fix it.
    – Harald Nordgren
    Nov 18 '18 at 21:05


















  • Could you include the rest of the code as well? The Go code, and how you build imagename?
    – Harald Nordgren
    Nov 18 '18 at 20:48










  • @HaraldNordgren the code worked fine (tried docker run -it and ran main manually which worked). it would log error if it couldnt build right ?
    – danicheeta
    Nov 18 '18 at 20:54










  • I didn't say there was anything wrong the rest of the code. But it helps us reproduce your exact problem to potentially help you fix it.
    – Harald Nordgren
    Nov 18 '18 at 21:05
















Could you include the rest of the code as well? The Go code, and how you build imagename?
– Harald Nordgren
Nov 18 '18 at 20:48




Could you include the rest of the code as well? The Go code, and how you build imagename?
– Harald Nordgren
Nov 18 '18 at 20:48












@HaraldNordgren the code worked fine (tried docker run -it and ran main manually which worked). it would log error if it couldnt build right ?
– danicheeta
Nov 18 '18 at 20:54




@HaraldNordgren the code worked fine (tried docker run -it and ran main manually which worked). it would log error if it couldnt build right ?
– danicheeta
Nov 18 '18 at 20:54












I didn't say there was anything wrong the rest of the code. But it helps us reproduce your exact problem to potentially help you fix it.
– Harald Nordgren
Nov 18 '18 at 21:05




I didn't say there was anything wrong the rest of the code. But it helps us reproduce your exact problem to potentially help you fix it.
– Harald Nordgren
Nov 18 '18 at 21:05












1 Answer
1






active

oldest

votes


















0














ENTRYPOINT /go


is equivalent to running /bin/sh -c /go



go is actually a directory in your container, so it will fail, because shell cannot execute a directory.



remove the background flag -d and use docker run imagename and you will see this error



What you probably want is:
ENTRYPOINT /usr/local/go/bin/go to use go as an executable from the container.



Or even better:



ENTRYPOINT ["/usr/local/go/bin/go"], so you would be able to pass arguments to go.






share|improve this answer























  • removed entrypoint and changed command to /go/main, doesnt work and doesnt show any error
    – danicheeta
    Nov 18 '18 at 21:17










  • include the output of: docker ps -n 1 --no-trunc
    – Uku Loskit
    Nov 18 '18 at 21:24










  • Exited (0) 12 minutes ago
    – danicheeta
    Nov 18 '18 at 21:29












  • please include the whole output
    – Uku Loskit
    Nov 18 '18 at 21:30










  • id:416f37a4af2150a3302dad7fcb1f8565d916eb55ce57d7113ea23099f2ef071c, k8s-temp_web:"/bin/bash", created:12 minutes ago, status:(0) 12 minutes ago, name:thirsty_northcutt
    – danicheeta
    Nov 19 '18 at 14:53













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%2f53365038%2fcontainer-keep-exiting-right-after-running-it%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














ENTRYPOINT /go


is equivalent to running /bin/sh -c /go



go is actually a directory in your container, so it will fail, because shell cannot execute a directory.



remove the background flag -d and use docker run imagename and you will see this error



What you probably want is:
ENTRYPOINT /usr/local/go/bin/go to use go as an executable from the container.



Or even better:



ENTRYPOINT ["/usr/local/go/bin/go"], so you would be able to pass arguments to go.






share|improve this answer























  • removed entrypoint and changed command to /go/main, doesnt work and doesnt show any error
    – danicheeta
    Nov 18 '18 at 21:17










  • include the output of: docker ps -n 1 --no-trunc
    – Uku Loskit
    Nov 18 '18 at 21:24










  • Exited (0) 12 minutes ago
    – danicheeta
    Nov 18 '18 at 21:29












  • please include the whole output
    – Uku Loskit
    Nov 18 '18 at 21:30










  • id:416f37a4af2150a3302dad7fcb1f8565d916eb55ce57d7113ea23099f2ef071c, k8s-temp_web:"/bin/bash", created:12 minutes ago, status:(0) 12 minutes ago, name:thirsty_northcutt
    – danicheeta
    Nov 19 '18 at 14:53


















0














ENTRYPOINT /go


is equivalent to running /bin/sh -c /go



go is actually a directory in your container, so it will fail, because shell cannot execute a directory.



remove the background flag -d and use docker run imagename and you will see this error



What you probably want is:
ENTRYPOINT /usr/local/go/bin/go to use go as an executable from the container.



Or even better:



ENTRYPOINT ["/usr/local/go/bin/go"], so you would be able to pass arguments to go.






share|improve this answer























  • removed entrypoint and changed command to /go/main, doesnt work and doesnt show any error
    – danicheeta
    Nov 18 '18 at 21:17










  • include the output of: docker ps -n 1 --no-trunc
    – Uku Loskit
    Nov 18 '18 at 21:24










  • Exited (0) 12 minutes ago
    – danicheeta
    Nov 18 '18 at 21:29












  • please include the whole output
    – Uku Loskit
    Nov 18 '18 at 21:30










  • id:416f37a4af2150a3302dad7fcb1f8565d916eb55ce57d7113ea23099f2ef071c, k8s-temp_web:"/bin/bash", created:12 minutes ago, status:(0) 12 minutes ago, name:thirsty_northcutt
    – danicheeta
    Nov 19 '18 at 14:53
















0












0








0






ENTRYPOINT /go


is equivalent to running /bin/sh -c /go



go is actually a directory in your container, so it will fail, because shell cannot execute a directory.



remove the background flag -d and use docker run imagename and you will see this error



What you probably want is:
ENTRYPOINT /usr/local/go/bin/go to use go as an executable from the container.



Or even better:



ENTRYPOINT ["/usr/local/go/bin/go"], so you would be able to pass arguments to go.






share|improve this answer














ENTRYPOINT /go


is equivalent to running /bin/sh -c /go



go is actually a directory in your container, so it will fail, because shell cannot execute a directory.



remove the background flag -d and use docker run imagename and you will see this error



What you probably want is:
ENTRYPOINT /usr/local/go/bin/go to use go as an executable from the container.



Or even better:



ENTRYPOINT ["/usr/local/go/bin/go"], so you would be able to pass arguments to go.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 18 '18 at 21:09

























answered Nov 18 '18 at 20:57









Uku LoskitUku Loskit

30.3k86879




30.3k86879












  • removed entrypoint and changed command to /go/main, doesnt work and doesnt show any error
    – danicheeta
    Nov 18 '18 at 21:17










  • include the output of: docker ps -n 1 --no-trunc
    – Uku Loskit
    Nov 18 '18 at 21:24










  • Exited (0) 12 minutes ago
    – danicheeta
    Nov 18 '18 at 21:29












  • please include the whole output
    – Uku Loskit
    Nov 18 '18 at 21:30










  • id:416f37a4af2150a3302dad7fcb1f8565d916eb55ce57d7113ea23099f2ef071c, k8s-temp_web:"/bin/bash", created:12 minutes ago, status:(0) 12 minutes ago, name:thirsty_northcutt
    – danicheeta
    Nov 19 '18 at 14:53




















  • removed entrypoint and changed command to /go/main, doesnt work and doesnt show any error
    – danicheeta
    Nov 18 '18 at 21:17










  • include the output of: docker ps -n 1 --no-trunc
    – Uku Loskit
    Nov 18 '18 at 21:24










  • Exited (0) 12 minutes ago
    – danicheeta
    Nov 18 '18 at 21:29












  • please include the whole output
    – Uku Loskit
    Nov 18 '18 at 21:30










  • id:416f37a4af2150a3302dad7fcb1f8565d916eb55ce57d7113ea23099f2ef071c, k8s-temp_web:"/bin/bash", created:12 minutes ago, status:(0) 12 minutes ago, name:thirsty_northcutt
    – danicheeta
    Nov 19 '18 at 14:53


















removed entrypoint and changed command to /go/main, doesnt work and doesnt show any error
– danicheeta
Nov 18 '18 at 21:17




removed entrypoint and changed command to /go/main, doesnt work and doesnt show any error
– danicheeta
Nov 18 '18 at 21:17












include the output of: docker ps -n 1 --no-trunc
– Uku Loskit
Nov 18 '18 at 21:24




include the output of: docker ps -n 1 --no-trunc
– Uku Loskit
Nov 18 '18 at 21:24












Exited (0) 12 minutes ago
– danicheeta
Nov 18 '18 at 21:29






Exited (0) 12 minutes ago
– danicheeta
Nov 18 '18 at 21:29














please include the whole output
– Uku Loskit
Nov 18 '18 at 21:30




please include the whole output
– Uku Loskit
Nov 18 '18 at 21:30












id:416f37a4af2150a3302dad7fcb1f8565d916eb55ce57d7113ea23099f2ef071c, k8s-temp_web:"/bin/bash", created:12 minutes ago, status:(0) 12 minutes ago, name:thirsty_northcutt
– danicheeta
Nov 19 '18 at 14:53






id:416f37a4af2150a3302dad7fcb1f8565d916eb55ce57d7113ea23099f2ef071c, k8s-temp_web:"/bin/bash", created:12 minutes ago, status:(0) 12 minutes ago, name:thirsty_northcutt
– danicheeta
Nov 19 '18 at 14:53




















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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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%2f53365038%2fcontainer-keep-exiting-right-after-running-it%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







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents