Docker Community Forums

Share and learn in the Docker community.

Unable to restart docker container with --restart 'always'

I had tried all the ways but unable to restart my docker container .If used --restart “always” it goes in to infinite loop of restarting .

Below is the configuration of Dockerfile:-

FROM continuumio/anaconda3:4.4.0
EXPOSE 8000
RUN echo "deb http://deb.debian.org/debian jessie main" > /etc/apt/sources.list
RUN apt-get update && apt-get install -y apache2 \
    apache2-dev \
    vim \
 && apt-get clean \
 && apt-get autoremove \
 && rm -rf /var/lib/apt/lists/* 
WORKDIR /var/www/test/
COPY ./test.wsgi /var/www/test/test.wsgi
COPY ./Demo /var/www/test/
RUN /opt/conda/bin/mod_wsgi-express install-module
RUN mod_wsgi-express setup-server test.wsgi --port=8000 \
    --user www-data --group www-data \
    --server-root=/etc/mod_wsgi-express-80
CMD /etc/mod_wsgi-express-80/apachectl start -D FOREGROUND

and is run the container using below command:-

docker run -d -p 8000:8000 --restart always test1

after restart of docker/server

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                          PORTS                  NAMES
f4ec5dc90809        test1                 "/usr/bin/tini -- /b…"   2 minutes ago       Restarting (0) 26 seconds ago                          practical_colden

I had tried on-failure also but not good result.

Logs of container

/etc/mod_wsgi-express-80/apachectl: line 63: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8): No such file or directory
httpd (pid 7) already running
/etc/mod_wsgi-express-80/apachectl: line 63: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8): No such file or directory
httpd (pid 7) already running
/etc/mod_wsgi-express-80/apachectl: line 63: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8): No such file or directory
httpd (pid 7) already running

You are fighting the wrong fight: first make sure your container starts properly and stays running. To do that you will need to modify your Dockerfile to fix whatever is wrong with it and create a new image.
Once you mastered that, you can move over to runtime details like restart conditions.

Can you tell me what changes i need to do where i am making mistakes