Docker.io init.d script not working on start container

后端 未结 5 1590
故里飘歌
故里飘歌 2021-02-02 17:31

I\'ve a container with odoo on it on the dir \"/opt/odoo/\".

A init script on \"/etc/init.d/odoo-server\"

#!/bin/bash
### BEGIN INIT INFO
# Provides:            


        
5条回答
  •  南笙
    南笙 (楼主)
    2021-02-02 18:07

    Now I tracked down the bug in some hours of work.

    The reason of the problem that start-stop-daemon, the main daemon starter/tester/stopper tool of the debian system, checks the existence of a daemon by examining the virtual soft link of the daemon process in /proc//exe (it should point to the binary image of the process started).

    Now the problem is, that in docker, this soft link simply won't work by default. It is because docker has to use strict security policies in the default install (it is used mainly to run unidentified software).

    There are many workarounds for the task, some needs to change the privilege settings of a container, some doesn't. Two examples:

    • You change your init scripts to not use start-stop-daemon with both the --test and --exec flags
    • You start your docker containers by giving --cap-add=SYS_ADMIN option to the docker run command (don't worry, it doesn't give your docker container any sysadm privileges, it is probably only a precaution for productive usage)

    Next to these, also systemd doesn't work in docker, although it is probably more a disadvantage of the systemd, as of the docker. Instead of the systemd, upstart is usable.


    P.s.: docker developers/advocates often say, "containers are not VMs" and similar. But, the in the everyday experience, there is no so really strong distinction between the two, and for a productive docker usage of the software, at least a minimal support of a VPS-like function would be surely useful. Hopefully also the docker development will focus their efforts in this direction in the near future.

提交回复
热议问题