Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to run prefork mode inside docker? 馃 #1021

renatojf opened this issue Nov 14, 2020 · 4 comments

Is it possible to run prefork mode inside docker? 馃 #1021

renatojf opened this issue Nov 14, 2020 · 4 comments


Copy link

Question description
When I run fiber with prefork: false inside docker, all works fine. prefork: true causes the container to panic out.

Code snippet Optional

package main

import ""

func main() {
  app := fiber.New(fiber.Config{
	Prefork: true,

go func() {
	if err := app.Listen(fmt.Sprintf(":%d", viper.GetInt("server.port"))); err != nil {

  c := make(chan os.Signal, 1)   // Create channel to signify a signal being sent
  signal.Notify(c, os.Interrupt) // When an interrupt is sent, notify the channel

  _ = <-c // This blocks the main thread until an interrupt is received
  fmt.Println("Gracefully shutting down...")
  _ = app.Shutdown()


$ docker run test
鈹屸攢鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹  鈹屸攢鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹
 鈹                    Fiber v2.2.0                   鈹  鈹 Child PIDs ... 16, 17, 21, 28                     鈹
 鈹                    鈹  鈹斺攢鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹
 鈹                                                   鈹
 鈹 Handlers ............. 7  Threads ............. 4 鈹
 鈹 Prefork ........ Enabled  PID ................. 1 鈹

2020/11/14 21:17:53 exit status 1
panic: exit status 1

goroutine 19 [running]:
log.Panic(0xc00009dfb8, 0x1, 0x1)
        /usr/local/go/src/log/log.go:351 +0xae
        /build/cmd/ad-delivery/main.go:55 +0x110
created by main.main
        /build/cmd/ad-delivery/main.go:53 +0x507
Copy link

welcome bot commented Nov 14, 2020

Thanks for opening your first issue here! 馃帀 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord

Copy link

hi019 commented Nov 19, 2020

We just did a little investigation in the Discord. Prefork uses environment variables so it will need to be executed within a shell. Docker docs:

Unlike the shell form, the exec form (CMD [...]) does not invoke a command shell. This means that normal shell processing does not happen. For example, CMD [ "echo", "$HOME" ] will not do variable substitution on $HOME. If you want shell processing then either use the shell form (CMD ./app) or execute a shell directly, for example: CMD [ "sh", "-c", "echo $HOME" ]. When using the exec form and executing a shell directly, as in the case for the shell form, it is the shell that is doing the environment variable expansion, not docker.

So execute your app with either CMD ./app or CMD ["sh", "-c", "/app"]. Let me know if this works.

We've also mentioned this case in the docs, gofiber/docs#144

Copy link

Sorry I have missed the discussion in the Discord chat :(
Thanks a lot for looking into this one. I confirm it runs perfectly now!

@hi019 hi019 closed this as completed Nov 20, 2020
Copy link

Another workaround if you still have a problem running Prefork: true inside a docker container

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

4 participants