Setup limitation - no systemd on my Docker image

We are planning to deploy ERPNext by leveraging Docker.
We have built a Centos 7 docker container that is used to run the setup script in the same way it has been done by David Gu in this example:

Docker container does not enable systemd to run in the container, unless you use certain privileges or loop holes ( see Blog Landing Page | Red Hat Developer for more details)

In our case, we have used supervisord in the Docker container to start and stop the different services during the ERPNext installation - I can share the Dockerfile and installation script if you are interested.

At some point during the ERPNext app installation, the frappe framework tries to restart its different services. While doing so, the framework check which service manager is used between systemd and service. If the installation script fails to identify one of those two, then the services are not restarted and the installation is aborted.

Here is my suggestion: It would be great to also check if supervisord is used as a service manager in the installation so that it can support this use case.
Let me know if you have other suggestions or ideas to workaround this issue.

CC: @pdvyas @anand


I’ve pushed a fix in bench.

You can set an environment variable: export BENCH_SERVICE_MANAGER=‘supervisorctl’ before installing and it should work.


Thanks a lot, Anand.
I am going to test it right away and keep you posted.


Hi Anand,

I have noticed that the fix also uses an addition env variable called BENCH_SERVICE_MANAGER_COMMAND.
So I have set it as well and everything seems to work well until the following error pops up:

Context = (Logged as root in the frappe-bench directory)





bench setup production erpnext

Restarted supervisord
error: <class ‘xmlrpclib.Fault’>, <Fault 6: ‘SHUTDOWN_STATE’>: file: /usr/lib64/python2.7/ line: 793

Should I try something differently?


Actually, in this case, if you’ve setup nginx/mysql/redis, etc via supervisor itself, we can skip calling restat_service('nginx') all together because we do a full supervisor reload just before that, so a feature like SKIP_RESTART_SERVICE would do the job.

If you can share your Dockerfile, I’ll make it working and submit to docker hub as well :smile:

cc: @anand

You don’t need to set the command. It is only in case the command is different from the one supplied.

Yes, that makes sense - no need to restart the service NGinx, you are right, Pratik.

Here is the Dockerfile - feel free to make some adjustments or suggestions before submitting to docker hub:

FROM centos:7

ENV HOSTNAME <set your hostname>

RUN yum -y update && yum -y clean all && yum update python -y
RUN yum -y install wget ca-certificates sudo rpm-cron python-setuptools MySQL-python httpd mysql mysql-server mysql-devel git memcached ntp vim
RUN easy_install pip && pip install pytz python-dateutil jinja2 markdown2 termcolor python-memcached requests chardet dropbox google-api-python-client pygeoip

RUN easy_install supervisor

# Create a new user for frappe
RUN useradd $FRAPPE_USER && chown -R $FRAPPE_USER.$FRAPPE_USER /home/$FRAPPE_USER && chmod a+x /home/$FRAPPE_USER

#Fix issue with /run write access
RUN chmod a+w /run


COPY /root/
# Need to preload the supervisord configuration as we use supervisord as a service manager
COPY all.conf /etc/supervisord.d/all.ini

# Copy the updated version of the frappe install script

# Running an updated version of the Frappe installation script
RUN bash --frappe-user $FRAPPE_USER --setup-production

# Make sure the volume is in sync with the frappe username
VOLUME ["/var/lib/mysql", "/home/erpnext/frappe-bench/sites/<type your sitename here>/"]

CMD ["/usr/bin/supervisord","-n"]
1 Like

Forgot to attach the all.conf file for CentOs7 - which is slightly different from the one published by David Gu for Debian.

all.conf file

command=/usr/bin/pidproxy /var/ /usr/bin/mysqld_safe --pid-file=/var/run/

command=/usr/bin/redis-server /etc/redis.conf

command=/usr/sbin/crond -n

command=/usr/sbin/nginx -g "daemon off;"
1 Like

Thanks, I’ll try this dockerfile today. Did you get it working?

Hi Pratik,

I still have an error message when completing the installation manually in my Centos7 Docker instance.
When running the last installation step of the setup script, I receive an error message regarding the command to restart NGinx - as you have mentioned earlier, we could skip this step since we do a full supervisor reload just before.

If you provide a feature like SKIP_RESTART_SERVICE, this could be a good workaround.

Here is the full trace:

# bench setup production erpnext
Restarted supervisord
error: <class 'xmlrpclib.Fault'>, <Fault 6: 'SHUTDOWN_STATE'>: file: /usr/lib64/python2.7/ line: 793
Traceback (most recent call last):
  File "/usr/bin/bench", line 9, in <module>
    load_entry_point('bench==0.92', 'console_scripts', 'bench')()
  File "/home/erpnext/bench-repo/bench/", line 60, in cli
  File "/usr/lib64/python2.7/site-packages/click/", line 700, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/click/", line 680, in main
    rv = self.invoke(ctx)
  File "/usr/lib64/python2.7/site-packages/click/", line 1027, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib64/python2.7/site-packages/click/", line 1027, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib64/python2.7/site-packages/click/", line 873, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib64/python2.7/site-packages/click/", line 508, in invoke
    return callback(*args, **kwargs)
  File "/home/erpnext/bench-repo/bench/", line 456, in setup_production
  File "/home/erpnext/bench-repo/bench/", line 67, in setup_production
  File "/home/erpnext/bench-repo/bench/", line 18, in restart_service
  File "/home/erpnext/bench-repo/bench/", line 104, in exec_cmd
    raise CommandFailedError(cmd)
bench.utils.CommandFailedError: supervisorctl restart nginx

Pushed. Just set SKIP_RESTART_SERVICE and try again

Thanks, Pratik.
I have tried it in my environment and after a few tries, I realized the variable is actually called “NO_SERVICE_RESTART”.
After setting it to true, it worked like a charm with no error code returned.
I am going to update my Dockerfile to include this change and generate a new image.

Thanks a lot for your support and help,


1 Like

Oops, sorry for that. Glad it worked. :smile:

@dgrelin Can you push your dockerfile to a repo so that we can officially publish it?


Sure, I need to make a few adjustments to make it generic and remove some custom pieces, like the default site name.
I should have this ready during next week.

1 Like

@dgrelin just stumbled over this thread from some time ago. Have you done a docker file which could be used in the meantime? Would you mind to post the docker repo here?

Hello @pdvyas, I see there’s a huge demand for an official docker setup and I’m interested as well. If I understand correctly you managed to make it working. Could you publish it on docker hub please?

mhmh… i guess no sharing. thanks :slight_smile:

@imapirate i found this after searching github GitHub - ianneub/docker-erpnext: Dockerized ERPNext or this Docker