# Infinite Restarts of docker container

**URL:** <https://forums.balena.io/t/infinite-restarts-of-docker-container/2712>\
**Category:** Product support\
**Tags:** raspberrypi3, docker\
**Created:** [March 14, 2018, 5:03pm UTC](https://forums.balena.io/t/infinite-restarts-of-docker-container/2712 "2018-03-14T17:03:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sebi55](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/sebi55/32/833_2.png) [@Sebi55](https://forums.balena.io/u/Sebi55)\
**Post date:** [March 14, 2018, 5:03pm UTC](https://forums.balena.io/t/infinite-restarts-of-docker-container/2712/1 "2018-03-14T17:03:00Z")

</div>

I have got the problem that I need to use Ubuntu 16.04 as docker image for my application because of some package dependencies and proprietary software.  
So I am sadly not able to rely on the resin base images.

I have now got everything setup from the docker side using armv7/armhf-ubuntu:xenial as image.  
But now my service/container exits every time immediately after executing.  
From my point of view this comes from the INITSYSTEM which is not enabled because I am not using a resin base image.  
What would be the best way or alternative to get the same behaviour as when using the INITSYSTEM?

This is the output in the console just to show what I mean:  
14.03.18 17:56:14 (+0100) main Hello, world!  
14.03.18 17:57:17 (+0100) main Hello, world!  
14.03.18 17:58:18 (+0100) main Hello, world!  
14.03.18 17:58:19 (+0100) Service exited ‘main sha256:c8c025f0fa851ce6cda70859c367ea7113d47176f63d5f66623ff43f374460cf’  
14.03.18 17:59:20 (+0100) Restarting service ‘main sha256:c8c025f0fa851ce6cda70859c367ea7113d47176f63d5f66623ff43f374460cf’  
28.02.18 07:08:46 (+0100) main Hello, world!  
28.02.18 07:08:49 (+0100) main Hello, world!  
28.02.18 07:08:51 (+0100) main Hello, world!

---

<div class="post-metadata">

**Author:** ![izavits](https://avatars.discourse-cdn.com/v4/letter/i/7feea3/32.png) [@izavits](https://forums.balena.io/u/izavits)\
**Post date:** [March 15, 2018, 3:23pm UTC](https://forums.balena.io/t/infinite-restarts-of-docker-container/2712/4 "2018-03-15T15:23:45Z")

</div>

Hello,  
have you tried enabling the init system either in the Dockerfile or via the Dashboard as described here? [https://docs.resin.io/learn/develop/dockerfile/#init-system](https://docs.resin.io/learn/develop/dockerfile/#init-system)

Otherwise, you should keep your process running. The container exits because the main process exits. So, I’d suggest you keep your program alive somehow.

---

<div class="post-metadata">

**Author:** ![Sebi55](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/sebi55/32/833_2.png) [@Sebi55](https://forums.balena.io/u/Sebi55)\
**Post date:** [March 20, 2018, 2:27pm UTC](https://forums.balena.io/t/infinite-restarts-of-docker-container/2712/5 "2018-03-20T14:27:33Z")

</div>

Yes this is enabled.

It works after just adding while(true) loop although I wouldn’t need it but that seems ok for me.

---

<div class="post-metadata">

**Author:** ![pcarranzav](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pcarranzav/32/94_2.png) [@pcarranzav](https://forums.balena.io/u/pcarranzav)\
**Post date:** [March 20, 2018, 7:23pm UTC](https://forums.balena.io/t/infinite-restarts-of-docker-container/2712/6 "2018-03-20T19:23:26Z")

</div>

@Sebi55 - indeed, the easiest way is to just keep your process running, which sometimes you can achieve by wrapping your process in a start script that just loops infinitely at the end. If you really want to replicate what INITSYSTEM does, you’d need to run systemd inside the ubuntu container - which could be really hard or really easy. It might help to look at how are debian images achieve this: [https://github.com/resin-io-library/base-images/blob/master/debian/entry.sh#L70](https://github.com/resin-io-library/base-images/blob/master/debian/entry.sh#L70) but I guess ubuntu may be a bit different.

---

<div class="post-metadata">

**Author:** ![pcarranzav](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pcarranzav/32/94_2.png) [@pcarranzav](https://forums.balena.io/u/pcarranzav)\
**Post date:** [March 20, 2018, 7:25pm UTC](https://forums.balena.io/t/infinite-restarts-of-docker-container/2712/7 "2018-03-20T19:25:21Z")

</div>

Also looking at this image might help [https://hub.docker.com/r/solita/ubuntu-systemd/~/dockerfile/](https://hub.docker.com/r/solita/ubuntu-systemd/~/dockerfile/) (haven’t tried it though)
