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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime error after first run #17

Closed
0atman opened this issue Nov 10, 2015 · 9 comments
Closed

Runtime error after first run #17

0atman opened this issue Nov 10, 2015 · 9 comments

Comments

@0atman
Copy link

0atman commented Nov 10, 2015

I'm trying to test dockerise using the nginx example, but when my container runs

ADD nginx.conf.tmpl /etc/nginx/nginx.conf.tmpl #my test tmpl, which doesn't use any 
CMD dockerize -template /etc/nginx/nginx.conf.tmpl:/etc/nginx/sites-available/default -stdout /var/log/nginx/access.log -stderr /var/log/nginx/error.log nginx

I get this scary stacktrace:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x403566]

goroutine 9 [running]:
main.tailFile(0x7fa0318de540, 0xc82004a340, 0x7ffc2a7adf0c, 0x18, 0xc820026018)
        /Users/jason/go/src/github.com/jwilder/dockerize/tail.go:34 +0x4f6
created by main.main
        /Users/jason/go/src/github.com/jwilder/dockerize/dockerize.go:131 +0xb83

goroutine 1 [semacquire]:
sync.runtime_Semacquire(0x6de90c)
        /usr/local/go/src/runtime/sema.go:43 +0x26
sync.(*WaitGroup).Wait(0x6de900)
        /usr/local/go/src/sync/waitgroup.go:126 +0xb4
main.main()
        /Users/jason/go/src/github.com/jwilder/dockerize/dockerize.go:134 +0xbb2

goroutine 5 [syscall]:
os/signal.loop()
        /usr/local/go/src/os/signal/signal_unix.go:22 +0x18
created by os/signal.init.1
        /usr/local/go/src/os/signal/signal_unix.go:28 +0x37

goroutine 7 [runnable]:
os/exec.(*Cmd).Start(0xc8200a0000, 0x0, 0x0)
        /usr/local/go/src/os/exec/exec.go:318 +0xb01
main.runCmd(0x7fa0318de540, 0xc82004a340, 0xc82000e4b0, 0x7ffc2a7adf25, 0x5, 0xc82000a1f0, 0x0, 0x0)
        /Users/jason/go/src/github.com/jwilder/dockerize/exec.go:23 +0x1d5
created by main.main
        /Users/jason/go/src/github.com/jwilder/dockerize/dockerize.go:121 +0x986

goroutine 8 [runnable]:
github.com/hpcloud/tail/watch.(*InotifyTracker).NewWatcher(0xc8200b2000, 0x0, 0x0, 0x0)
        /Users/jason/go/src/github.com/hpcloud/tail/watch/inotify_tracker.go:27 +0xe0
github.com/hpcloud/tail.TailFile(0x7ffc2a7adeea, 0x19, 0x0, 0x1, 0x0, 0x1, 0x0, 0xc8200101e0, 0x0, 0x0, ...)
        /Users/jason/go/src/github.com/hpcloud/tail/tail.go:106 +0x5af
main.tailFile(0x7fa0318de540, 0xc82004a340, 0x7ffc2a7adeea, 0x19, 0xc820026010)
        /Users/jason/go/src/github.com/jwilder/dockerize/tail.go:19 +0x123
created by main.main
        /Users/jason/go/src/github.com/jwilder/dockerize/dockerize.go:126 +0xa75

goroutine 10 [runnable]:
gopkg.in/fsnotify%2ev0.(*Watcher).readEvents(0xc820014360)
        ?:0
created by gopkg.in/fsnotify%2ev0.NewWatcher
        ?:0 +0x40b

goroutine 11 [runnable]:
gopkg.in/fsnotify%2ev0.(*Watcher).purgeEvents(0xc820014360)
        /Users/jason/go/src/gopkg.in/fsnotify.v0/fsnotify.go:20
created by gopkg.in/fsnotify%2ev0.NewWatcher
        ?:0 +0x42d

goroutine 17 [runnable]:
gopkg.in/fsnotify%2ev0.(*Watcher).readEvents(0xc8200ac180)
        ?:0
created by gopkg.in/fsnotify%2ev0.NewWatcher
        ?:0 +0x40b

goroutine 18 [runnable]:
gopkg.in/fsnotify%2ev0.(*Watcher).purgeEvents(0xc8200ac180)
        /Users/jason/go/src/gopkg.in/fsnotify.v0/fsnotify.go:20
created by gopkg.in/fsnotify%2ev0.NewWatcher
        ?:0 +0x42d
@0atman
Copy link
Author

0atman commented Nov 11, 2015

Do I need some kind of go standard library?

@0atman
Copy link
Author

0atman commented Nov 11, 2015

Could this be causing trouble?

/var/log/nginx# ls -al
total 8
drwxr-xr-x 2 root root 4096 Oct 28 22:01 .
drwxr-xr-x 9 root root 4096 Nov 10 15:06 ..
lrwxrwxrwx 1 root root   11 Oct 28 22:01 access.log -> /dev/stdout
lrwxrwxrwx 1 root root   11 Oct 28 22:01 error.log -> /dev/stderr

@0atman
Copy link
Author

0atman commented Nov 11, 2015

If I leave off -stdout /var/log/nginx/access.log -stderr /var/log/nginx/error.log it runs (though I'm not sure yet if it works)

@0atman
Copy link
Author

0atman commented Nov 11, 2015

Oh! the offical docker nginx repo makes these links:

https://github.com/nginxinc/docker-nginx/blob/4e5332fa50a1f8f73657417c6bfe249bbb3b110d/Dockerfile#L15

RUN ln -sf /dev/stdout /var/log/nginx/access.log
RUN ln -sf /dev/stderr /var/log/nginx/error.log

Is that what's causing the failure?

@0atman
Copy link
Author

0atman commented Nov 11, 2015

Can confirm that replacing the links with regular files fixes the stacktrace, when using -stdout /var/log/nginx/access.log -stderr /var/log/nginx/error.log

@0atman
Copy link
Author

0atman commented Nov 11, 2015

Proposed fix:

Defensively code the part that redirects log files to stdout/error.

@0atman
Copy link
Author

0atman commented Nov 11, 2015

I'd do it, but I'm no go pro!

@0atman 0atman changed the title Panic after firstrun Runtime error after firstrun Nov 11, 2015
@0atman 0atman changed the title Runtime error after firstrun Runtime error after first run Nov 11, 2015
@sstarcher
Copy link
Contributor

Could this be related to overlayfs?
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/882147
moby/moby#11705

@ghost
Copy link

ghost commented Jan 11, 2016

RUN ln -sf /dev/stdout /var/log/nginx/access.log
RUN ln -sf /dev/stderr /var/log/nginx/error.log

It's have same effect like dockerize's -stdout /var/log/nginx/access.log -stderr /var/log/nginx/error.log, but the ln -sf way is better, because dockerzie don't cleans already forwarded lines from logs and container continues growing.

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

No branches or pull requests

2 participants