Why the docker container not picking the source code changes

coder used Ask the Experts™
Hi Experts,

     docker container is not picking the recent changes from the source code.     it makes me to build the docker image every time to see the latest changes on the source code.

Please find below the contents of the Dockerfile

FROM ubuntu:16.04


RUN apt-get update -y
RUN apt-get install -y software-properties-common python-software-properties curl
RUN add-apt-repository -y ppa:fkrull/deadsnakes

RUN apt-get update -y && apt-get install -y curl
RUN apt-get update -y && apt-get install -y \
	git \
	python3.6 \
	python3.6-dev \
	nginx \
	sqlite3 \
	nodejs \
	build-essential \
	libmagickwand-dev \
	cron \

RUN rm -f /usr/bin/python3
RUN ln -s /usr/bin/python3.6 /usr/bin/python3
RUN curl https://bootstrap.pypa.io/get-pip.py | python3

WORKDIR /home/trove
COPY . .

COPY build/docker/uwsgi_params .
COPY build/docker/uwsgi.ini .
RUN pip3 install --no-cache-dir uwsgi
RUN pip3 install --no-cache-dir -r requirements.txt

COPY build/docker/start /usr/bin/
COPY build/docker/crontab /etc/cron.d/harvest-cron
RUN chmod 0644 /etc/cron.d/harvest-cron
RUN touch /var/log/harvest.log

RUN echo "daemon off;" >> /etc/nginx/nginx.conf
COPY build/docker/nginx-app.conf /etc/nginx/sites-available/default
COPY build/docker/start /usr/bin/
RUN mkdir /var/log/harvest/
RUN python3 manage.py collectstatic --noinput

WORKDIR /home/trove/
RUN chmod 755 /home/trove
RUN chown -R www-data:www-data /home/trove

CMD ["start"]

Open in new window

please find below the contents of the crontab

* * * * * root ( source /tmp/environment.sh && /usr/bin/python3 /home/trove/run.py $(cat /tmp/method) ) >> /dev/null 2>/var/log/harvest/ts_errors.log

Open in new window

the commands I use in putty shell is

docker build -t harvest-trove:1.0.3 .

for building the image.

then I log into aws cli,

aws configure && $(aws ecr get-login --no-include-email --region ap-southeast-2)
  Access Key ID: ************
  Secret: **************

Then I tag the docker images to

docker tag harvest-trove:1.0.3 940233033813.dkr.ecr.ap-southeast-2.amazonaws.com/harvest-trove:1.0.3

then push the image

docker push 940233033813.dkr.ecr.ap-southeast-2.amazonaws.com/harvest-trove:1.0.3

create environment variables

declare -a trove_environment=(-e ELASTICSEARCH="[\"\"]" -e STATIC_PATH='/trove/static/' -e CLOUD_WATCH=true -e SCRIPT_NAME=/trove -e AWS_ACCESS_KEY_ID=***********  -e "AWS_SECRET_ACCESS_KEY=**************"  -e AWS_DEFAULT_REGION=ap-southeast-2 -e PRODUCTION=true -e "DATABASE=postgres://trove:******@" -e "TROVE_KEY=*********" -e "SECONDS_BETWEEN_HARVESTING=72000" -e "ITEMS_PER_FETCH=20" -e "EXIT_AFTER_X_SECONDS=300"  -e "ELASTICSEARCH_INDEX=ntdl" -e "TROVE_API_BASE_URL=http://api.trove.nla.gov.au/result" -e "TERRITORY_STORIES_URL=territorystories.nt.gov.au" -e "HARVEST_PREFIX_URL=trove" -e "S3_BUCKET=*****" -e "S3_SITEMAP_PATH=sitemap" -e "SECONDS_BETWEEN_SITEMAPS=86400" -e "LOCAL_URL_PREFIX=https://ntl-ntdl-dev10.s3.amazonaws.com")

docker run ${trove_environment[@]} -ti 940233033813.dkr.ecr.ap-southeast-2.amazonaws.com/harvest-trove:1.0.3 python3.6 manage.py migrate

docker run --name trove_pull ${trove_environment[@]} -d --restart always 940233033813.dkr.ecr.ap-southeast-2.amazonaws.com/harvest-trove:1.0.3 start pull

docker run --name trove_process ${trove_environment[@]} -d --restart always 940233033813.dkr.ecr.ap-southeast-2.amazonaws.com/harvest-trove:1.0.3 start process

I got the above steps from the documentation which we have already which are used in the demo machine.

I want to create a development environment, are the steps are right for the development environment

My questions are

a) It makes me to build  the docker image every time to see the latest changes.  is there any way I make changes in the source code it gets picked up by the container and it reflects it every time when I run the container.  

b) why I have tag the built image.

c) Why I have to login to aws and push the image to aws.

d) in the following command

docker run --name trove_pull ${trove_environment[@]} -d --restart always 940233033813.dkr.ecr.ap-southeast-2.amazonaws.com/harvest-trove:1.0.3 start pull

where from the following id

940233033813.dkr.ecr.ap-southeast-2.amazonaws.com/harvest-trove:1.0.3  is picked?  how they arrive at this id?

This is id I tag the image and push the image to aws.

All these steps are done at the demo machine.  I am trying to do this above steps on the development machine to make the development environment.

Please clarify my doubts and throw some light over it.

With many thanks,

Bharath AK
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
DevOps Engineer
Distinguished Expert 2018
can you put the source code in shared folder from host to docker container.


Hi Prabin,

        The source code is not opensource,  I can't share the source code.  Basically it fetches information from trove through Api's and it stores information to database, and elasticsearch and s3 on aws.   We create many instances of the same application, with many command line options like fetch, process and push to elasticsearch.  The application is executed on crontab it works for few seconds then it stops and starts with the help of crontab.

with many thanks

Bharath AK


Hi Prabhin,

          Sorry for the confusion, I misunderstood what you had said.

With Many thanks,
Bharath AK

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial