Container immediately exits with error code 137

Post Reply
tietje
New here
Posts: 3
Joined: Sun Jun 12, 2016 8:14 pm

Container immediately exits with error code 137

Post by tietje » Sun May 19, 2019 1:42 am

Hi guys!

I'm attempting to create a Transmission container with integrated OpenVPN client, but right after startup it exits with code 137, without any information. It manages to connect to the VPN server, all seems well and *boom*. Below is the selection of my docker-compose:

transmission:
image: haugene/transmission-openvpn
cap_add:
- NET_ADMIN
devices:
- /dev/net/tun
restart: unless-stopped
ports:
- "9091:9091"
- "8888:8888"
dns:
- 8.8.8.8
- 8.8.4.4
volumes:
- "/share/Container/Docker/openvpn_config:/vpn"
- "/share/Container/Docker/openvpn_config/config.ovpn:/etc/openvpn/custom/default.ovpn"
environment:
- OPENVPN_PROVIDER=CUSTOM
- OPENVPN_USERNAME=bla
- OPENVPN_PASSWORD=bla
- CREATE_TUN_DEVICE=true
- WEBPROXY_ENABLED=true
- WEBPROXY_PORT=8888
networks:
- backend


One more observation is that this exact same docker-compose works fine on OS X... I've also tried another container: https://github.com/dperson/openvpn-client, which has the same issue. Other docker containers work fine. I'm using a TS453a with 8 GBs of RAM.

Google-ing this issue points me to out-of-memory issues. The NAS reports 4GB+ of free memory. Also stopping all(8) other containers still makes the openVPN container to exit with code 137.

Have any of you also encountered this issue? I'm very curious if someone has some insights in this. I have the feeling it might be something in the OS...

Thanks!

tietje
New here
Posts: 3
Joined: Sun Jun 12, 2016 8:14 pm

Re: Container immediately exits with error code 137

Post by tietje » Fri May 24, 2019 3:52 am

Let me reply to my own question, since I managed to solve the issue. The trick is to completely remove the QVPN app. After this, reboot the NAS (make sure the QVPN app is not automatically reinstalled).

This is my working docker-compose snippet:


# NOTE: Uninstall QVPN app to make this work on QTS 4.3.6!
transmission:
container_name: transmission-openvpn
image: haugene/transmission-openvpn
cap_add:
- NET_ADMIN
restart: unless-stopped
ports:
- 9091:9091
- 8888:8888
dns:
- 8.8.8.8
- 8.8.4.4
volumes:
- "/share/Container/Docker/openvpn_config:/vpn"
- "/share/Container/Docker/openvpn_config/config.ovpn:/etc/openvpn/custom/default.ovpn"
environment:
- GROUPID=1000
- USERID=1000
- OPENVPN_PROVIDER=CUSTOM
- OPENVPN_USERNAME=bla
- OPENVPN_PASSWORD=bla
# - OPENVPN_OPTS=--ping-exit 60
- CREATE_TUN_DEVICE=true
- WEBPROXY_ENABLED=true
- WEBPROXY_PORT=8888
networks:
- backend

Cheers!

mseewald
Starting out
Posts: 20
Joined: Sat Nov 11, 2017 9:38 pm

Re: Container immediately exits with error code 137

Post by mseewald » Sat Nov 09, 2019 6:36 pm

I can confirm the problem still exists as of November 2019 with latest QTS, QVPN and haugene/transmission-openvpn image installed.

Explanation: It appears to be caused by a supervisor process watching for and killing any "openvpn" process other than the one from QVPN. This happens every couple of seconds which explains that you can successfully start up the docker image, but then it stops without any connectivity issue.

Solution: Simply rename the openvpn binary during the 5-10 seconds it is running and make sure it is found under the new name:
> sed -i 's/exec openvpn/exec myopenvpn/g' /etc/openvpn/start.sh ; mv /usr/sbin/openvpn /usr/sbin/myopenvpn

This can be done using portainer's console feature.

Enjoy!

purplefish
New here
Posts: 5
Joined: Fri Nov 30, 2007 12:57 am

Re: Container immediately exits with error code 137

Post by purplefish » Tue Nov 12, 2019 5:14 am

mseewald wrote:
Sat Nov 09, 2019 6:36 pm
I can confirm the problem still exists as of November 2019 with latest QTS, QVPN and haugene/transmission-openvpn image installed.

Explanation: It appears to be caused by a supervisor process watching for and killing any "openvpn" process other than the one from QVPN. This happens every couple of seconds which explains that you can successfully start up the docker image, but then it stops without any connectivity issue.

Solution: Simply rename the openvpn binary during the 5-10 seconds it is running and make sure it is found under the new name:
> sed -i 's/exec openvpn/exec myopenvpn/g' /etc/openvpn/start.sh ; mv /usr/sbin/openvpn /usr/sbin/myopenvpn

This can be done using portainer's console feature.

Enjoy!
Could I ask you to put a couple of more words on what to do and when to do it? I find this extreemly frustrating and would like not have to disable QVPN.

mobilcontrol
New here
Posts: 4
Joined: Wed Dec 18, 2019 10:15 am

Re: Container immediately exits with error code 137

Post by mobilcontrol » Wed Dec 18, 2019 12:19 pm

I'm also curious where and how to enable this command.
Thanks

mseewald
Starting out
Posts: 20
Joined: Sat Nov 11, 2017 9:38 pm

Re: Container immediately exits with error code 137

Post by mseewald » Sun Dec 29, 2019 7:44 am

Apologies. I saw these replies only just now .. I should activate email notifications to be a more responsive forum member ..

These steps should be helpful to understand the solution in greater detail:

1) activate ssh and login into your QNAP box as admin
2) go to a directory, where you feel comfortable storing some docker configuration (e.g. /share/homes/admin/transmissionvpn)
3) create file "docker-compose.yml" and adjust as needed

Code: Select all

version: '2'

services:
  transmission-vpn:
    image: haugene/transmission-openvpn
    container_name: transmission-vpn
    cap_add:
      - NET_ADMIN
    dns:
      - 195.186.1.162
      - 8.8.4.4
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /share/homes/admin/transmissionvpn/data:/data
    environment:
      - CREATE_TUN_DEVICE=true
      - OPENVPN_OPTS=--inactive 3600 --ping 10 --ping-exit 60
      - OPENVPN_PROVIDER=NEWSHOSTING
      - OPENVPN_CONFIG=default
      - OPENVPN_USERNAME=changetoyouruser
      - OPENVPN_PASSWORD=changetoyourpwd
      - LOCAL_NETWORK=192.168.86.0/24
      - PUID=1000000
      - PGID=1000000
      - TRANSMISSION_RPC_AUTHENTICATION_REQUIRED=true
      - TRANSMISSION_RPC_HOST_WHITELIST="192.168.86.*"
      - TRANSMISSION_RPC_USERNAME=youradmin
      - TRANSMISSION_RPC_PASSWORD=youradminpwd
      - TRANSMISSION_UMASK=002
      - TRANSMISSION_RATIO_LIMIT=1.00
      - TRANSMISSION_RATIO_LIMIT_ENABLED=true
    ports:
      - 39091:9091
    network_mode: bridge
    restart: always
4) execute in the chosen location (e.g. in /share/homes/admin/transmissionvpn):

Code: Select all

docker-compose up -d
DOCKERID=`docker ps | grep transmissionvpn | awk '{print $1}'`
docker exec -it $DOCKERID sed -i 's/exec openvpn/exec myopenvpn/g' /etc/openvpn/start.sh
docker exec -it $DOCKERID mv /usr/sbin/openvpn /usr/sbin/myopenvpn
5) check that docker container is running stably, e.g. via QNAP docker tool
6) check if process "myopenvpn" is running instead of "openvpn", e.g. using ps in ssh shell

Code: Select all

ps | grep myopenvpn
Of note, there is another image "dceschmidt/openvpn-proxy" that can be used to launch proxies e.g. to be used by FoxyProxy (e.g. 1 for each country of choice). The startup script is called differently, but otherwise all same.

Hope it helps & please feel free to let me know questions.

Dusha
Starting out
Posts: 44
Joined: Tue Mar 22, 2011 2:25 pm

Re: Container immediately exits with error code 137

Post by Dusha » Sat May 09, 2020 7:16 pm

mseewald wrote:
Sun Dec 29, 2019 7:44 am

Code: Select all

docker exec -it $DOCKERID sed -i 's/exec openvpn/exec myopenvpn/g' /etc/openvpn/start.sh
docker exec -it $DOCKERID mv /usr/sbin/openvpn /usr/sbin/myopenvpn

Hi, I assume that this need to be done after every QNAP reboot (and container restart / update of the version)?
Any way to automate this?

Meanwhile will proceed with complete QVPN removal...
TS459-Pro+ >> TS-453B-4G

mseewald
Starting out
Posts: 20
Joined: Sat Nov 11, 2017 9:38 pm

Re: Container immediately exits with error code 137

Post by mseewald » Sat May 09, 2020 7:43 pm

You only need to do it when you pull a new container image. Restart of container or Qnap NAS does not impact the change.

Dusha
Starting out
Posts: 44
Joined: Tue Mar 22, 2011 2:25 pm

Re: Container immediately exits with error code 137

Post by Dusha » Sat May 09, 2020 7:52 pm

How to prevent QVPN from re-installing after each reboot???
TS459-Pro+ >> TS-453B-4G

Dusha
Starting out
Posts: 44
Joined: Tue Mar 22, 2011 2:25 pm

Re: Container immediately exits with error code 137

Post by Dusha » Sat May 09, 2020 7:57 pm

mseewald wrote:
Sat May 09, 2020 7:43 pm
You only need to do it when you pull a new container image. Restart of container or Qnap NAS does not impact the change.
yes, thanks, got it.
I'm using watchtower for automatic updates, posted a question to devs on github:
https://github.com/haugene/docker-trans ... ssues/1172

maybe changing the binary name could be considered by devs in the future releases.

Now I'm struggling to permanently remove QVPN service from my NAS, as it gets re-installed on each reboot!
Any ideas?

UPDATE:
after removing QVPN and rebooting for the 2nd time it was not re-installed... weird.
TS459-Pro+ >> TS-453B-4G

User avatar
beneix
Getting the hang of things
Posts: 89
Joined: Wed May 26, 2010 5:16 am
Location: UK

Re: Container immediately exits with error code 137

Post by beneix » Sun Sep 20, 2020 5:19 pm

I have been tearing my hair out trying to sort this very issue - this thread gives me hope! Thanks mseewald!

@mseewald - I have two questions:
1. When discussing "uninstalling" the QVPN service, is this the stopping of the service or the complete removal?
2. Is the renaming of the openvpn binary an alternative to getting rid of the QVPN service, or do you need to do both?
TS-119 QTS4.3.3.1252 Build 20200409 | Seagate ST4000VN000 4TB

mseewald
Starting out
Posts: 20
Joined: Sat Nov 11, 2017 9:38 pm

Re: Container immediately exits with error code 137

Post by mseewald » Sun Sep 20, 2020 8:56 pm

beneix wrote:
Sun Sep 20, 2020 5:19 pm
1. When discussing "uninstalling" the QVPN service, is this the stopping of the service or the complete removal?
2. Is the renaming of the openvpn binary an alternative to getting rid of the QVPN service, or do you need to do both?
To clarify, by patching the binary inside the docker image, you can keep QVPN installed and running.
So,
1- either or should work (but at least for myself, I wanted to keep QVPN installed and running, that’s why the patch was necessary)
2- yes, patching the docker image is the alternative to removing or stopping the service. but you need to patch this every time you pull a fresh image.

User avatar
beneix
Getting the hang of things
Posts: 89
Joined: Wed May 26, 2010 5:16 am
Location: UK

Re: Container immediately exits with error code 137

Post by beneix » Sun Sep 20, 2020 11:11 pm

Thanks mseewald. Having read up a bit further, it turns out another option is to stop the daemon process that looks for openvpn processes and kills them. Instructions here:

https://reddit.com/r/qnap/comments/gsa3 ... onopenvpn/

That way, you can keep QVPN service running alongside haugene.
TS-119 QTS4.3.3.1252 Build 20200409 | Seagate ST4000VN000 4TB

mseewald
Starting out
Posts: 20
Joined: Sat Nov 11, 2017 9:38 pm

Re: Container immediately exits with error code 137

Post by mseewald » Mon Sep 21, 2020 12:25 am

beneix wrote:
Sun Sep 20, 2020 11:11 pm
That way, you can keep QVPN service running alongside haugene.
not sure what you mean. I am running both on my side as well.

of course, you are free to patch QNAP instead of the haugene docker image. but as long as nobody knows why QNAP implemented the kill watchdog, I will prefer to patch the docker image.

Post Reply

Return to “Container Station”