title: How to update source code without rebuilding image each time?
body: <p>Is there a way to avoid rebuilding my Docker image each time I make a change in my source code ?</p>
  <p>I think I have already optimize my Dockerfile enough to decrease building time, but it's always 2 commands and some waiting time for sometimes just one line of code added. It's longer than a simple CTRL + S and check the results.</p>
  <p>The commands I have to do for each little update in my code:</p>
  <pre><code>docker-compose down
  docker-compose build
  docker-compose up
  </code></pre>
  <p>Here's my Dockerfile:</p>
  <pre><code>FROM python:3-slim as development
  
  ENV PYTHONUNBUFFERED=1
  
  COPY ./requirements.txt /requirements.txt
  COPY ./scripts /scripts
  
  EXPOSE 80
  
  RUN apt-get update &amp;&amp; \
      apt-get install -y \
      bash \
      build-essential \
      gcc \
      libffi-dev \
      musl-dev \
      openssl \
      wget \
      postgresql \
      postgresql-client \
      libglib2.0-0 \
      libnss3 \
      libgconf-2-4 \
      libfontconfig1 \
      libpq-dev &amp;&amp; \
      pip install -r /requirements.txt &amp;&amp; \
      mkdir -p /vol/web/static &amp;&amp; \
      chmod -R 755 /vol &amp;&amp; \
      chmod -R +x /scripts
  
  COPY ./files /files
  
  WORKDIR /files
  
  ENV PATH=&quot;/scripts:/py/bin:$PATH&quot;
  
  CMD [&quot;run.sh&quot;]
  </code></pre>
  <p>Here's my docker-compose.yml file:</p>
  <pre><code>version: '3.9'
  
  x-database-variables: &amp;database-variables
    POSTGRES_DB: ${POSTGRES_DB}
    POSTGRES_USER: ${POSTGRES_USER}
    POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    ALLOWED_HOSTS: ${ALLOWED_HOSTS}
  
  x-app-variables: &amp;app-variables
    &lt;&lt;: *database-variables
    POSTGRES_HOST: ${POSTGRES_HOST}
    SPOTIPY_CLIENT_ID: ${SPOTIPY_CLIENT_ID}
    SPOTIPY_CLIENT_SECRET: ${SPOTIPY_CLIENT_SECRET}
    SECRET_KEY: ${SECRET_KEY}
    CLUSTER_HOST: ${CLUSTER_HOST}
    DEBUG: 0
  
  services:
    website:
      build:
        context: .
      restart: always
      volumes:
        - static-data:/vol/web
      environment: *app-variables
      depends_on:
        - postgres
  
    postgres:
      image: postgres
      restart: always
      environment: *database-variables
      volumes:
        - db-data:/var/lib/postgresql/data
  
    proxy:
      build:
        context: ./proxy
      restart: always
      depends_on:
        - website
      ports:
        - 80:80
        - 443:443
      volumes:
        - static-data:/vol/static
        - ./files/templates:/var/www/html
        - ./proxy/default.conf:/etc/nginx/conf.d/default.conf
        - ./etc/letsencrypt:/etc/letsencrypt
  
  volumes:
    static-data:
    db-data:
  </code></pre>