Phyton How to update code from Git to a Docker container update python code from 2 to 3

There are a couple of approaches you can use.

  1. You can use docker build --no-cache to avoid using the cache of the Git clone.
  2. The startup command calls git pull. So instead of running python manage.py, you'd have something like CMD cd /repo && git pull && python manage.py or use a start script if things are more complex.

I tend to prefer 2. You can also run a cron job to update the code in your container, but that's a little more work and goes somewhat against the Docker philosophy.

Answer:1

I would recommend you checkout out the code on your host and COPY it into the image. That way it will be updated whenever you make a change. Also, during development you can bind mount the source directory over the code directory in the container, meaning any changes are reflected immediately in the container.

A docker command for git repositories that checks for the last update would be very useful though!

Answer:2

Another solution.

Docker build command uses cache as long as a instruction string is exactly same as the one of cached image. So, if you write

RUN echo '2014122400' >/dev/null && git pull ...

On next update, you change as follows.

RUN echo '2014122501' >/dev/null && git pull ...

This can prevents docker from using cache.

Answer:3



  1. update python code from 2 to 3

I've been playing with the community edition of JetBrains ItelliJ IDEA since it came out, and I really like it; however, a lot of plugins seem to require the ultimate edition (or at least I think they ...

I've been playing with the community edition of JetBrains ItelliJ IDEA since it came out, and I really like it; however, a lot of plugins seem to require the ultimate edition (or at least I think they ...

Is there an easy way with python's logging module to send messages with a DEBUG or INFO level and the one with a higher level to different streams? Is it a good idea anyway?

Is there an easy way with python's logging module to send messages with a DEBUG or INFO level and the one with a higher level to different streams? Is it a good idea anyway?