docker container exits on entry pointsHow is Docker different from a virtual machine?Should I use Vagrant or Docker for creating an isolated environment?How to list containers in DockerHow to get a Docker container's IP address from the host?How to remove old Docker containersHow to deal with persistent storage (e.g. databases) in DockerCopying files from Docker container to hostCopying files from host to Docker containerHow to copy Docker images from one host to another without using a repositoryFrom inside of a Docker container, how do I connect to the localhost of the machine?

How does one intimidate enemies without having the capacity for violence?

How can I fix this gap between bookcases I made?

Is there really no realistic way for a skeleton monster to move around without magic?

What is the offset in a seaplane's hull?

Why CLRS example on residual networks does not follows its formula?

Why did the Germans forbid the possession of pet pigeons in Rostov-on-Don in 1941?

How do we improve the relationship with a client software team that performs poorly and is becoming less collaborative?

Why is an old chain unsafe?

Download, install and reboot computer at night if needed

What is the meaning of "of trouble" in the following sentence?

I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine

What do you call something that goes against the spirit of the law, but is legal when interpreting the law to the letter?

Why is the design of haulage companies so “special”?

Copycat chess is back

XeLaTeX and pdfLaTeX ignore hyphenation

Are tax years 2016 & 2017 back taxes deductible for tax year 2018?

least quadratic residue under GRH: an EXPLICIT bound

Shell script can be run only with sh command

DOS, create pipe for stdin/stdout of command.com(or 4dos.com) in C or Batch?

Motorized valve interfering with button?

Concept of linear mappings are confusing me

Why Is Death Allowed In the Matrix?

Can Medicine checks be used, with decent rolls, to completely mitigate the risk of death from ongoing damage?

Chess with symmetric move-square



docker container exits on entry points


How is Docker different from a virtual machine?Should I use Vagrant or Docker for creating an isolated environment?How to list containers in DockerHow to get a Docker container's IP address from the host?How to remove old Docker containersHow to deal with persistent storage (e.g. databases) in DockerCopying files from Docker container to hostCopying files from host to Docker containerHow to copy Docker images from one host to another without using a repositoryFrom inside of a Docker container, how do I connect to the localhost of the machine?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








3















I am trying to run a docker container through Dockerfile with docker run command. Following is my Dockerfile.



FROM python:3.6
# for imaging stuff
RUN apt-get update
RUN apt install libmagickwand-dev
# Create app directory
RUN mkdir -p /home/test/app
# Install Libre Office and ghostscript for pdf conversion and repairing
RUN apt-get update -qq
&& apt-get install -y -q libreoffice
&& apt-get remove -q -y libreoffice-gnome
&& apt-get update
&& apt-get -y install ghostscript
&& apt-get -y install nano
&& apt-get -y install poppler-utils
&& apt-get install -y nginx
# Cleanup after apt-get commands
RUN apt-get clean
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
/var/cache/apt/archives/*.deb /var/cache/apt/*cache.bin
# Activate WORKING DIR
WORKDIR /home/test/app
# Initiating devnull directory
RUN mkdir -p dev_null
# Copying requirements
COPY requirements/local.txt /tmp/requirements.txt
# Install the app dependencies
RUN pip install -r /tmp/requirements.txt
COPY id_rsa /root/.ssh/id_rsa
COPY requirements/private.txt /tmp/private.txt
RUN ssh-keyscan -T 60 bitbucket.org >> /root/.ssh/known_hosts
&& chmod 600 /root/.ssh/id_rsa
&& pip install -r /tmp/private.txt
# Envs
ENV DJANGO_SETTINGS_MODULE app.settings.local
ENV ENVIORNMENT local
# ADD the source code and entry point into the container
ADD . /home/test/app
ADD docker-entrypoint.sh /home/test/app/docker-entrypoint.sh
# Making entry point executable
RUN apt-get update && apt-get install -y supervisor
&& apt-get install -y nginx
#RUN mkdir -p /var/log/test
#COPY supervisor.conf /etc/supervisor/conf.d/supervisor.conf
RUN chmod +x docker-entrypoint.sh
RUN mkdir -p /var/log/test
COPY supervisor.conf /etc/supervisor/conf.d/supervisor.conf
# Exposing port


# Copy entrypoint script into the image
COPY ./docker-entrypoint.sh /
COPY ./django_nginx.conf /etc/nginx/
RUN chmod +x start.sh

#RUN chmod +x /docker-entrypoint.sh
EXPOSE 8000
ENTRYPOINT ["bash", "/docker-entrypoint.sh"]
CMD ["bash", "/home/test/app/start.sh"]


and the following are my entry points.



#!/usr/bin/env bash
set -e

# ToDo Need to enable this
#until psql $DATABASE_URL -c 'l'; do
# >&2 echo "Postgres is unavailable - sleeping"
# sleep 1
#done
#
#>&2 echo "Postgres is up - continuing"
cd app
mkdir -p app/keys
if [[ ! -e /var/log/gunicorn-access.log ]]; then
touch /var/log/gunicorn-access.log
fi
if [[ ! -e /var/log/gunicorn-error.log ]]; then
touch /var/log/gunicorn-error.log
fi

if [ "x$DJANGO_MANAGEPY_MIGRATE" = 'xon' ]; then
echo "Django starting to migrate un-applied migrations"
python manage.py migrate --noinput
fi

if [ "x$DJANGO_MANAGEPY_COLLECTSTATIC" = 'xon' ]; then
echo "Django starting to collect static data"
python manage.py collectstatic --noinput
fi

if [ "x$DJANGO_LOADDATA" = 'xon' ]; then
python manage.py loaddata taxing/fixtures/province-taxing-table-initial-data.json
fi

if [ "x$LOAD_TEMPLATE_FROM_S3" = 'xtrue' ]; then
echo "loading s3"
python manage.py loadindex

fi


# Start Gunicorn processes
echo Starting Gunicorn.
exec gunicorn test.wsgi:application
--name test
--workers 3
--log-level=info
--log-file=/srv/logs/gunicorn.log
--access-logfile=/srv/logs/access.log &

exec service nginx start


and following is my start.sh



#!/bin/bash

echo "I am running"
echo "Belive me"
/usr/bin/supervisord -n


and i am building the container with docker build -t test . and it is building just fine. But when i try to run this container using docker run --name test --env-file ./env test my container exits on ["bash", "/docker-entrypoint.sh"] command of Dockerfile without any errors/message but if I remove the entrypoint command from Dockerfile it's working just fine. I am unable to find out the mistake. Any help is appreciated.










share|improve this question






























    3















    I am trying to run a docker container through Dockerfile with docker run command. Following is my Dockerfile.



    FROM python:3.6
    # for imaging stuff
    RUN apt-get update
    RUN apt install libmagickwand-dev
    # Create app directory
    RUN mkdir -p /home/test/app
    # Install Libre Office and ghostscript for pdf conversion and repairing
    RUN apt-get update -qq
    && apt-get install -y -q libreoffice
    && apt-get remove -q -y libreoffice-gnome
    && apt-get update
    && apt-get -y install ghostscript
    && apt-get -y install nano
    && apt-get -y install poppler-utils
    && apt-get install -y nginx
    # Cleanup after apt-get commands
    RUN apt-get clean
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
    /var/cache/apt/archives/*.deb /var/cache/apt/*cache.bin
    # Activate WORKING DIR
    WORKDIR /home/test/app
    # Initiating devnull directory
    RUN mkdir -p dev_null
    # Copying requirements
    COPY requirements/local.txt /tmp/requirements.txt
    # Install the app dependencies
    RUN pip install -r /tmp/requirements.txt
    COPY id_rsa /root/.ssh/id_rsa
    COPY requirements/private.txt /tmp/private.txt
    RUN ssh-keyscan -T 60 bitbucket.org >> /root/.ssh/known_hosts
    && chmod 600 /root/.ssh/id_rsa
    && pip install -r /tmp/private.txt
    # Envs
    ENV DJANGO_SETTINGS_MODULE app.settings.local
    ENV ENVIORNMENT local
    # ADD the source code and entry point into the container
    ADD . /home/test/app
    ADD docker-entrypoint.sh /home/test/app/docker-entrypoint.sh
    # Making entry point executable
    RUN apt-get update && apt-get install -y supervisor
    && apt-get install -y nginx
    #RUN mkdir -p /var/log/test
    #COPY supervisor.conf /etc/supervisor/conf.d/supervisor.conf
    RUN chmod +x docker-entrypoint.sh
    RUN mkdir -p /var/log/test
    COPY supervisor.conf /etc/supervisor/conf.d/supervisor.conf
    # Exposing port


    # Copy entrypoint script into the image
    COPY ./docker-entrypoint.sh /
    COPY ./django_nginx.conf /etc/nginx/
    RUN chmod +x start.sh

    #RUN chmod +x /docker-entrypoint.sh
    EXPOSE 8000
    ENTRYPOINT ["bash", "/docker-entrypoint.sh"]
    CMD ["bash", "/home/test/app/start.sh"]


    and the following are my entry points.



    #!/usr/bin/env bash
    set -e

    # ToDo Need to enable this
    #until psql $DATABASE_URL -c 'l'; do
    # >&2 echo "Postgres is unavailable - sleeping"
    # sleep 1
    #done
    #
    #>&2 echo "Postgres is up - continuing"
    cd app
    mkdir -p app/keys
    if [[ ! -e /var/log/gunicorn-access.log ]]; then
    touch /var/log/gunicorn-access.log
    fi
    if [[ ! -e /var/log/gunicorn-error.log ]]; then
    touch /var/log/gunicorn-error.log
    fi

    if [ "x$DJANGO_MANAGEPY_MIGRATE" = 'xon' ]; then
    echo "Django starting to migrate un-applied migrations"
    python manage.py migrate --noinput
    fi

    if [ "x$DJANGO_MANAGEPY_COLLECTSTATIC" = 'xon' ]; then
    echo "Django starting to collect static data"
    python manage.py collectstatic --noinput
    fi

    if [ "x$DJANGO_LOADDATA" = 'xon' ]; then
    python manage.py loaddata taxing/fixtures/province-taxing-table-initial-data.json
    fi

    if [ "x$LOAD_TEMPLATE_FROM_S3" = 'xtrue' ]; then
    echo "loading s3"
    python manage.py loadindex

    fi


    # Start Gunicorn processes
    echo Starting Gunicorn.
    exec gunicorn test.wsgi:application
    --name test
    --workers 3
    --log-level=info
    --log-file=/srv/logs/gunicorn.log
    --access-logfile=/srv/logs/access.log &

    exec service nginx start


    and following is my start.sh



    #!/bin/bash

    echo "I am running"
    echo "Belive me"
    /usr/bin/supervisord -n


    and i am building the container with docker build -t test . and it is building just fine. But when i try to run this container using docker run --name test --env-file ./env test my container exits on ["bash", "/docker-entrypoint.sh"] command of Dockerfile without any errors/message but if I remove the entrypoint command from Dockerfile it's working just fine. I am unable to find out the mistake. Any help is appreciated.










    share|improve this question


























      3












      3








      3








      I am trying to run a docker container through Dockerfile with docker run command. Following is my Dockerfile.



      FROM python:3.6
      # for imaging stuff
      RUN apt-get update
      RUN apt install libmagickwand-dev
      # Create app directory
      RUN mkdir -p /home/test/app
      # Install Libre Office and ghostscript for pdf conversion and repairing
      RUN apt-get update -qq
      && apt-get install -y -q libreoffice
      && apt-get remove -q -y libreoffice-gnome
      && apt-get update
      && apt-get -y install ghostscript
      && apt-get -y install nano
      && apt-get -y install poppler-utils
      && apt-get install -y nginx
      # Cleanup after apt-get commands
      RUN apt-get clean
      && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
      /var/cache/apt/archives/*.deb /var/cache/apt/*cache.bin
      # Activate WORKING DIR
      WORKDIR /home/test/app
      # Initiating devnull directory
      RUN mkdir -p dev_null
      # Copying requirements
      COPY requirements/local.txt /tmp/requirements.txt
      # Install the app dependencies
      RUN pip install -r /tmp/requirements.txt
      COPY id_rsa /root/.ssh/id_rsa
      COPY requirements/private.txt /tmp/private.txt
      RUN ssh-keyscan -T 60 bitbucket.org >> /root/.ssh/known_hosts
      && chmod 600 /root/.ssh/id_rsa
      && pip install -r /tmp/private.txt
      # Envs
      ENV DJANGO_SETTINGS_MODULE app.settings.local
      ENV ENVIORNMENT local
      # ADD the source code and entry point into the container
      ADD . /home/test/app
      ADD docker-entrypoint.sh /home/test/app/docker-entrypoint.sh
      # Making entry point executable
      RUN apt-get update && apt-get install -y supervisor
      && apt-get install -y nginx
      #RUN mkdir -p /var/log/test
      #COPY supervisor.conf /etc/supervisor/conf.d/supervisor.conf
      RUN chmod +x docker-entrypoint.sh
      RUN mkdir -p /var/log/test
      COPY supervisor.conf /etc/supervisor/conf.d/supervisor.conf
      # Exposing port


      # Copy entrypoint script into the image
      COPY ./docker-entrypoint.sh /
      COPY ./django_nginx.conf /etc/nginx/
      RUN chmod +x start.sh

      #RUN chmod +x /docker-entrypoint.sh
      EXPOSE 8000
      ENTRYPOINT ["bash", "/docker-entrypoint.sh"]
      CMD ["bash", "/home/test/app/start.sh"]


      and the following are my entry points.



      #!/usr/bin/env bash
      set -e

      # ToDo Need to enable this
      #until psql $DATABASE_URL -c 'l'; do
      # >&2 echo "Postgres is unavailable - sleeping"
      # sleep 1
      #done
      #
      #>&2 echo "Postgres is up - continuing"
      cd app
      mkdir -p app/keys
      if [[ ! -e /var/log/gunicorn-access.log ]]; then
      touch /var/log/gunicorn-access.log
      fi
      if [[ ! -e /var/log/gunicorn-error.log ]]; then
      touch /var/log/gunicorn-error.log
      fi

      if [ "x$DJANGO_MANAGEPY_MIGRATE" = 'xon' ]; then
      echo "Django starting to migrate un-applied migrations"
      python manage.py migrate --noinput
      fi

      if [ "x$DJANGO_MANAGEPY_COLLECTSTATIC" = 'xon' ]; then
      echo "Django starting to collect static data"
      python manage.py collectstatic --noinput
      fi

      if [ "x$DJANGO_LOADDATA" = 'xon' ]; then
      python manage.py loaddata taxing/fixtures/province-taxing-table-initial-data.json
      fi

      if [ "x$LOAD_TEMPLATE_FROM_S3" = 'xtrue' ]; then
      echo "loading s3"
      python manage.py loadindex

      fi


      # Start Gunicorn processes
      echo Starting Gunicorn.
      exec gunicorn test.wsgi:application
      --name test
      --workers 3
      --log-level=info
      --log-file=/srv/logs/gunicorn.log
      --access-logfile=/srv/logs/access.log &

      exec service nginx start


      and following is my start.sh



      #!/bin/bash

      echo "I am running"
      echo "Belive me"
      /usr/bin/supervisord -n


      and i am building the container with docker build -t test . and it is building just fine. But when i try to run this container using docker run --name test --env-file ./env test my container exits on ["bash", "/docker-entrypoint.sh"] command of Dockerfile without any errors/message but if I remove the entrypoint command from Dockerfile it's working just fine. I am unable to find out the mistake. Any help is appreciated.










      share|improve this question
















      I am trying to run a docker container through Dockerfile with docker run command. Following is my Dockerfile.



      FROM python:3.6
      # for imaging stuff
      RUN apt-get update
      RUN apt install libmagickwand-dev
      # Create app directory
      RUN mkdir -p /home/test/app
      # Install Libre Office and ghostscript for pdf conversion and repairing
      RUN apt-get update -qq
      && apt-get install -y -q libreoffice
      && apt-get remove -q -y libreoffice-gnome
      && apt-get update
      && apt-get -y install ghostscript
      && apt-get -y install nano
      && apt-get -y install poppler-utils
      && apt-get install -y nginx
      # Cleanup after apt-get commands
      RUN apt-get clean
      && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
      /var/cache/apt/archives/*.deb /var/cache/apt/*cache.bin
      # Activate WORKING DIR
      WORKDIR /home/test/app
      # Initiating devnull directory
      RUN mkdir -p dev_null
      # Copying requirements
      COPY requirements/local.txt /tmp/requirements.txt
      # Install the app dependencies
      RUN pip install -r /tmp/requirements.txt
      COPY id_rsa /root/.ssh/id_rsa
      COPY requirements/private.txt /tmp/private.txt
      RUN ssh-keyscan -T 60 bitbucket.org >> /root/.ssh/known_hosts
      && chmod 600 /root/.ssh/id_rsa
      && pip install -r /tmp/private.txt
      # Envs
      ENV DJANGO_SETTINGS_MODULE app.settings.local
      ENV ENVIORNMENT local
      # ADD the source code and entry point into the container
      ADD . /home/test/app
      ADD docker-entrypoint.sh /home/test/app/docker-entrypoint.sh
      # Making entry point executable
      RUN apt-get update && apt-get install -y supervisor
      && apt-get install -y nginx
      #RUN mkdir -p /var/log/test
      #COPY supervisor.conf /etc/supervisor/conf.d/supervisor.conf
      RUN chmod +x docker-entrypoint.sh
      RUN mkdir -p /var/log/test
      COPY supervisor.conf /etc/supervisor/conf.d/supervisor.conf
      # Exposing port


      # Copy entrypoint script into the image
      COPY ./docker-entrypoint.sh /
      COPY ./django_nginx.conf /etc/nginx/
      RUN chmod +x start.sh

      #RUN chmod +x /docker-entrypoint.sh
      EXPOSE 8000
      ENTRYPOINT ["bash", "/docker-entrypoint.sh"]
      CMD ["bash", "/home/test/app/start.sh"]


      and the following are my entry points.



      #!/usr/bin/env bash
      set -e

      # ToDo Need to enable this
      #until psql $DATABASE_URL -c 'l'; do
      # >&2 echo "Postgres is unavailable - sleeping"
      # sleep 1
      #done
      #
      #>&2 echo "Postgres is up - continuing"
      cd app
      mkdir -p app/keys
      if [[ ! -e /var/log/gunicorn-access.log ]]; then
      touch /var/log/gunicorn-access.log
      fi
      if [[ ! -e /var/log/gunicorn-error.log ]]; then
      touch /var/log/gunicorn-error.log
      fi

      if [ "x$DJANGO_MANAGEPY_MIGRATE" = 'xon' ]; then
      echo "Django starting to migrate un-applied migrations"
      python manage.py migrate --noinput
      fi

      if [ "x$DJANGO_MANAGEPY_COLLECTSTATIC" = 'xon' ]; then
      echo "Django starting to collect static data"
      python manage.py collectstatic --noinput
      fi

      if [ "x$DJANGO_LOADDATA" = 'xon' ]; then
      python manage.py loaddata taxing/fixtures/province-taxing-table-initial-data.json
      fi

      if [ "x$LOAD_TEMPLATE_FROM_S3" = 'xtrue' ]; then
      echo "loading s3"
      python manage.py loadindex

      fi


      # Start Gunicorn processes
      echo Starting Gunicorn.
      exec gunicorn test.wsgi:application
      --name test
      --workers 3
      --log-level=info
      --log-file=/srv/logs/gunicorn.log
      --access-logfile=/srv/logs/access.log &

      exec service nginx start


      and following is my start.sh



      #!/bin/bash

      echo "I am running"
      echo "Belive me"
      /usr/bin/supervisord -n


      and i am building the container with docker build -t test . and it is building just fine. But when i try to run this container using docker run --name test --env-file ./env test my container exits on ["bash", "/docker-entrypoint.sh"] command of Dockerfile without any errors/message but if I remove the entrypoint command from Dockerfile it's working just fine. I am unable to find out the mistake. Any help is appreciated.







      docker dockerfile docker-build docker-entrypoint docker-run






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 8 at 16:40









      Dheeraj Kumar

      304212




      304212










      asked Mar 8 at 6:09









      Shoaib IqbalShoaib Iqbal

      525416




      525416






















          2 Answers
          2






          active

          oldest

          votes


















          0














          if your image builds successfully then you may try to append this line in you start.sh



          tail -f /etc/issue


          your start.sh may looks like then:



          #!/bin/bash

          echo "I am running"
          echo "Belive me"
          /usr/bin/supervisord -n
          tail -f /etc/issue





          share|improve this answer























          • tried that but still no improvement. container exits after executing last line entrypoints i.e starting nginx. following messages are printed upon running container. Starting Gunicorn. Starting nginx: nginx.

            – Shoaib Iqbal
            Mar 8 at 6:22











          • another fix CMD ["/bin/bash", "/home/test/app/start.sh"]

            – Vijay Dohare
            Mar 8 at 6:30











          • no luck Vijay. still exiting. if i remove entrypoints command from Dockerfile then its working just fine.

            – Shoaib Iqbal
            Mar 8 at 6:33











          • try to run the run command in detached mode docker run -dit --name test --env-file ./env test and then try to execute /home/test/app/start.sh to verify if the script is executable or not. press ctrl+d to exit

            – Vijay Dohare
            Mar 8 at 6:43











          • tried docker run -dit --name test --env-file ./env test but still container exits on entrypoints.

            – Shoaib Iqbal
            Mar 8 at 6:52


















          0














          Here's what I see happening in this sequence:



          ENTRYPOINT ["bash", "/docker-entrypoint.sh"]
          CMD ["bash", "/home/test/app/start.sh"]


          When you start the container, Docker runs bash /docker-entrypoint.sh bash /home/test/app/start.sh. However, the entrypoint script never looks at its command-line arguments at all, so any CMD you specify here or any command you give at the end of the docker run command line gets completely ignored.



          When that entrypoint script runs:



          exec gunicorn ... &
          exec service nginx start
          # end of file


          it starts gunicorn as a background process and continues to the next line; then it replaces itself with a service command. That service command becomes the main container process and has process ID 1. It starts nginx, and immediately returns. Now that the main container process has returned, the container exits.




          For this code as you've written it, you should delete the exec lines at the end of your entrypoint script and replace them with just



          exec "$@"


          which will cause the shell to run its command-line parameters (that is, the Dockerfile CMD).



          However, there's a readily available nginx Docker image. Generally if you need multiple processes, it's easier and better to run them as two separate containers on the same Docker network. This avoids the complexities around trying to get multiple things running in the same container.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55057650%2fdocker-container-exits-on-entry-points%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            if your image builds successfully then you may try to append this line in you start.sh



            tail -f /etc/issue


            your start.sh may looks like then:



            #!/bin/bash

            echo "I am running"
            echo "Belive me"
            /usr/bin/supervisord -n
            tail -f /etc/issue





            share|improve this answer























            • tried that but still no improvement. container exits after executing last line entrypoints i.e starting nginx. following messages are printed upon running container. Starting Gunicorn. Starting nginx: nginx.

              – Shoaib Iqbal
              Mar 8 at 6:22











            • another fix CMD ["/bin/bash", "/home/test/app/start.sh"]

              – Vijay Dohare
              Mar 8 at 6:30











            • no luck Vijay. still exiting. if i remove entrypoints command from Dockerfile then its working just fine.

              – Shoaib Iqbal
              Mar 8 at 6:33











            • try to run the run command in detached mode docker run -dit --name test --env-file ./env test and then try to execute /home/test/app/start.sh to verify if the script is executable or not. press ctrl+d to exit

              – Vijay Dohare
              Mar 8 at 6:43











            • tried docker run -dit --name test --env-file ./env test but still container exits on entrypoints.

              – Shoaib Iqbal
              Mar 8 at 6:52















            0














            if your image builds successfully then you may try to append this line in you start.sh



            tail -f /etc/issue


            your start.sh may looks like then:



            #!/bin/bash

            echo "I am running"
            echo "Belive me"
            /usr/bin/supervisord -n
            tail -f /etc/issue





            share|improve this answer























            • tried that but still no improvement. container exits after executing last line entrypoints i.e starting nginx. following messages are printed upon running container. Starting Gunicorn. Starting nginx: nginx.

              – Shoaib Iqbal
              Mar 8 at 6:22











            • another fix CMD ["/bin/bash", "/home/test/app/start.sh"]

              – Vijay Dohare
              Mar 8 at 6:30











            • no luck Vijay. still exiting. if i remove entrypoints command from Dockerfile then its working just fine.

              – Shoaib Iqbal
              Mar 8 at 6:33











            • try to run the run command in detached mode docker run -dit --name test --env-file ./env test and then try to execute /home/test/app/start.sh to verify if the script is executable or not. press ctrl+d to exit

              – Vijay Dohare
              Mar 8 at 6:43











            • tried docker run -dit --name test --env-file ./env test but still container exits on entrypoints.

              – Shoaib Iqbal
              Mar 8 at 6:52













            0












            0








            0







            if your image builds successfully then you may try to append this line in you start.sh



            tail -f /etc/issue


            your start.sh may looks like then:



            #!/bin/bash

            echo "I am running"
            echo "Belive me"
            /usr/bin/supervisord -n
            tail -f /etc/issue





            share|improve this answer













            if your image builds successfully then you may try to append this line in you start.sh



            tail -f /etc/issue


            your start.sh may looks like then:



            #!/bin/bash

            echo "I am running"
            echo "Belive me"
            /usr/bin/supervisord -n
            tail -f /etc/issue






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 8 at 6:18









            Vijay DohareVijay Dohare

            529217




            529217












            • tried that but still no improvement. container exits after executing last line entrypoints i.e starting nginx. following messages are printed upon running container. Starting Gunicorn. Starting nginx: nginx.

              – Shoaib Iqbal
              Mar 8 at 6:22











            • another fix CMD ["/bin/bash", "/home/test/app/start.sh"]

              – Vijay Dohare
              Mar 8 at 6:30











            • no luck Vijay. still exiting. if i remove entrypoints command from Dockerfile then its working just fine.

              – Shoaib Iqbal
              Mar 8 at 6:33











            • try to run the run command in detached mode docker run -dit --name test --env-file ./env test and then try to execute /home/test/app/start.sh to verify if the script is executable or not. press ctrl+d to exit

              – Vijay Dohare
              Mar 8 at 6:43











            • tried docker run -dit --name test --env-file ./env test but still container exits on entrypoints.

              – Shoaib Iqbal
              Mar 8 at 6:52

















            • tried that but still no improvement. container exits after executing last line entrypoints i.e starting nginx. following messages are printed upon running container. Starting Gunicorn. Starting nginx: nginx.

              – Shoaib Iqbal
              Mar 8 at 6:22











            • another fix CMD ["/bin/bash", "/home/test/app/start.sh"]

              – Vijay Dohare
              Mar 8 at 6:30











            • no luck Vijay. still exiting. if i remove entrypoints command from Dockerfile then its working just fine.

              – Shoaib Iqbal
              Mar 8 at 6:33











            • try to run the run command in detached mode docker run -dit --name test --env-file ./env test and then try to execute /home/test/app/start.sh to verify if the script is executable or not. press ctrl+d to exit

              – Vijay Dohare
              Mar 8 at 6:43











            • tried docker run -dit --name test --env-file ./env test but still container exits on entrypoints.

              – Shoaib Iqbal
              Mar 8 at 6:52
















            tried that but still no improvement. container exits after executing last line entrypoints i.e starting nginx. following messages are printed upon running container. Starting Gunicorn. Starting nginx: nginx.

            – Shoaib Iqbal
            Mar 8 at 6:22





            tried that but still no improvement. container exits after executing last line entrypoints i.e starting nginx. following messages are printed upon running container. Starting Gunicorn. Starting nginx: nginx.

            – Shoaib Iqbal
            Mar 8 at 6:22













            another fix CMD ["/bin/bash", "/home/test/app/start.sh"]

            – Vijay Dohare
            Mar 8 at 6:30





            another fix CMD ["/bin/bash", "/home/test/app/start.sh"]

            – Vijay Dohare
            Mar 8 at 6:30













            no luck Vijay. still exiting. if i remove entrypoints command from Dockerfile then its working just fine.

            – Shoaib Iqbal
            Mar 8 at 6:33





            no luck Vijay. still exiting. if i remove entrypoints command from Dockerfile then its working just fine.

            – Shoaib Iqbal
            Mar 8 at 6:33













            try to run the run command in detached mode docker run -dit --name test --env-file ./env test and then try to execute /home/test/app/start.sh to verify if the script is executable or not. press ctrl+d to exit

            – Vijay Dohare
            Mar 8 at 6:43





            try to run the run command in detached mode docker run -dit --name test --env-file ./env test and then try to execute /home/test/app/start.sh to verify if the script is executable or not. press ctrl+d to exit

            – Vijay Dohare
            Mar 8 at 6:43













            tried docker run -dit --name test --env-file ./env test but still container exits on entrypoints.

            – Shoaib Iqbal
            Mar 8 at 6:52





            tried docker run -dit --name test --env-file ./env test but still container exits on entrypoints.

            – Shoaib Iqbal
            Mar 8 at 6:52













            0














            Here's what I see happening in this sequence:



            ENTRYPOINT ["bash", "/docker-entrypoint.sh"]
            CMD ["bash", "/home/test/app/start.sh"]


            When you start the container, Docker runs bash /docker-entrypoint.sh bash /home/test/app/start.sh. However, the entrypoint script never looks at its command-line arguments at all, so any CMD you specify here or any command you give at the end of the docker run command line gets completely ignored.



            When that entrypoint script runs:



            exec gunicorn ... &
            exec service nginx start
            # end of file


            it starts gunicorn as a background process and continues to the next line; then it replaces itself with a service command. That service command becomes the main container process and has process ID 1. It starts nginx, and immediately returns. Now that the main container process has returned, the container exits.




            For this code as you've written it, you should delete the exec lines at the end of your entrypoint script and replace them with just



            exec "$@"


            which will cause the shell to run its command-line parameters (that is, the Dockerfile CMD).



            However, there's a readily available nginx Docker image. Generally if you need multiple processes, it's easier and better to run them as two separate containers on the same Docker network. This avoids the complexities around trying to get multiple things running in the same container.






            share|improve this answer



























              0














              Here's what I see happening in this sequence:



              ENTRYPOINT ["bash", "/docker-entrypoint.sh"]
              CMD ["bash", "/home/test/app/start.sh"]


              When you start the container, Docker runs bash /docker-entrypoint.sh bash /home/test/app/start.sh. However, the entrypoint script never looks at its command-line arguments at all, so any CMD you specify here or any command you give at the end of the docker run command line gets completely ignored.



              When that entrypoint script runs:



              exec gunicorn ... &
              exec service nginx start
              # end of file


              it starts gunicorn as a background process and continues to the next line; then it replaces itself with a service command. That service command becomes the main container process and has process ID 1. It starts nginx, and immediately returns. Now that the main container process has returned, the container exits.




              For this code as you've written it, you should delete the exec lines at the end of your entrypoint script and replace them with just



              exec "$@"


              which will cause the shell to run its command-line parameters (that is, the Dockerfile CMD).



              However, there's a readily available nginx Docker image. Generally if you need multiple processes, it's easier and better to run them as two separate containers on the same Docker network. This avoids the complexities around trying to get multiple things running in the same container.






              share|improve this answer

























                0












                0








                0







                Here's what I see happening in this sequence:



                ENTRYPOINT ["bash", "/docker-entrypoint.sh"]
                CMD ["bash", "/home/test/app/start.sh"]


                When you start the container, Docker runs bash /docker-entrypoint.sh bash /home/test/app/start.sh. However, the entrypoint script never looks at its command-line arguments at all, so any CMD you specify here or any command you give at the end of the docker run command line gets completely ignored.



                When that entrypoint script runs:



                exec gunicorn ... &
                exec service nginx start
                # end of file


                it starts gunicorn as a background process and continues to the next line; then it replaces itself with a service command. That service command becomes the main container process and has process ID 1. It starts nginx, and immediately returns. Now that the main container process has returned, the container exits.




                For this code as you've written it, you should delete the exec lines at the end of your entrypoint script and replace them with just



                exec "$@"


                which will cause the shell to run its command-line parameters (that is, the Dockerfile CMD).



                However, there's a readily available nginx Docker image. Generally if you need multiple processes, it's easier and better to run them as two separate containers on the same Docker network. This avoids the complexities around trying to get multiple things running in the same container.






                share|improve this answer













                Here's what I see happening in this sequence:



                ENTRYPOINT ["bash", "/docker-entrypoint.sh"]
                CMD ["bash", "/home/test/app/start.sh"]


                When you start the container, Docker runs bash /docker-entrypoint.sh bash /home/test/app/start.sh. However, the entrypoint script never looks at its command-line arguments at all, so any CMD you specify here or any command you give at the end of the docker run command line gets completely ignored.



                When that entrypoint script runs:



                exec gunicorn ... &
                exec service nginx start
                # end of file


                it starts gunicorn as a background process and continues to the next line; then it replaces itself with a service command. That service command becomes the main container process and has process ID 1. It starts nginx, and immediately returns. Now that the main container process has returned, the container exits.




                For this code as you've written it, you should delete the exec lines at the end of your entrypoint script and replace them with just



                exec "$@"


                which will cause the shell to run its command-line parameters (that is, the Dockerfile CMD).



                However, there's a readily available nginx Docker image. Generally if you need multiple processes, it's easier and better to run them as two separate containers on the same Docker network. This avoids the complexities around trying to get multiple things running in the same container.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 8 at 11:38









                David MazeDavid Maze

                15.8k31531




                15.8k31531



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55057650%2fdocker-container-exits-on-entry-points%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    1928 у кіно

                    Захаров Федір Захарович

                    Ель Греко