Have you ever wanted to keep a docker container running in the background of your host machine, without the need for a bash entry-point?
Let’s get started installing ubuntu and configuring our instance.
Your Ubuntu 18.04 docker image will require a one-time configuration of Supervisord to get started with process monitoring.
Supervisord — A Process Control System, which will run and manage your command-based programs from a simple configuration file setup.
Let’s first create a docker file to help install ubuntu from DockerHub.
FROM ubuntu:18.04
RUN apt-get update && \
apt-get install -y supervisor && \
apt-get clean
RUN mkdir -p /var/log/supervisor
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
EXPOSE 8089
CMD ["/usr/bin/supervisord"]
To create a long-running process ID on start-up, Supervisord needs to be installed on Ubuntu. The docker file will include a configuration file for Supervisord to read from the directory /etc/supervisor/conf.d/supervisord.conf
[supervisord]
logfile=/var/log/supervisor/supervisord.log
pidfile=/var/run/supervisord.pid
nodaemon=true
You will be able to access a running docker container without the need for a _bash file _script running on start-up.
An example of a_ bash file_ script in docker would utilize an entry point of ENTRYPOINT ["/bin/bash", "/bootstrap.sh"]
This long-running process started in the background is created with the help of the command line tool “Supervisorctl”. This tool connects to a UNIX or TCP socket and initializes a “program” or “service” on the host machine.
Let’s look at the output log for clarity.
#docker-container #docker-run #supervisord #ubuntu