title: How to update content in docker container?
body: <p>I have a docker-compose.yml like this, just 3 services, php, application and database:</p>
  <pre><code>version: &quot;3.8&quot;
  services:
  
    app:
      ports:
        - 8002
      build:
        context: &quot;app/nginx&quot;
        dockerfile: Dockerfile
      volumes:
        - app-volume:/app
      depends_on:
        - app-php-fpm
  
    app-php-fpm:
      build:
        context: app/php-fpm
        dockerfile: Dockerfile
      volumes:
        - app-volume:/app
  
    app-db-postgreSQL:
      image: postgres:14.0
      ports:
        - &quot;5432:5432&quot;
      environment:
        POSTGRES_USER: ${POSTGRES_USER}
        POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
        POSTGRES_DB: ${POSTGRES_DB}
      volumes:
        - app-postgres:/var/lib/postgresql/data
  
  volumes:
    app-volume:
  </code></pre>
  <p>In my application, I just changed one line of code from this:</p>
  <pre><code>Route::get('/', function () {
      return view('welcome');
  });
  </code></pre>
  <p>on this:</p>
  <pre><code>Route::get('/', function () {
      return response()-&gt;json(DB::table('playWithDocker')-&gt;get()-&gt;toArray());
  });
  </code></pre>
  <p>I committed the changes to github, then stopped all containers with the command:</p>
  <pre><code>docker-compose down --remove-orphans
  </code></pre>
  <p>Then I rebuilt the docker image of the application with the command:</p>
  <pre><code>docker-compose build --no-cache app
  </code></pre>
  <p>And again launched all the containers:</p>
  <pre><code>docker-compose up --build -d
  </code></pre>
  <p>But, the content of the app container has not changed.
  It only changes if I remove the volume <code>app-volume</code> with the command:</p>
  <pre><code>docker-compose down --remove-orphans -v
  </code></pre>
  <p>And recreate the containers again:</p>
  <pre><code>docker-compose up --build -d
  </code></pre>
  <p>But I think it's wrong to delete volumes every time with <code>-v</code>. So I don't really understand how I can update the contents of my application docker container.</p>
  <p>My app/nginx/Dockerfile:</p>
  <pre><code>FROM composer as vendor
  
  # Install git.
  RUN apk update &amp;&amp; apk add git
  
  # Set working directory.
  WORKDIR /app
  
  # Cloning application from a private repository on github.
  RUN git clone https://${USERNAME}:${TOKEN}@github.com/${USERNAME}/play-with-docker.com.git .
  
  # Install dependencies with the `composer install` command.
  RUN composer install \
      --ignore-platform-reqs \
      --no-interaction \
      --no-plugins \
      --no-scripts \
      --prefer-dist
  
  
  FROM nginx:1.21.3-alpine
  
  # Copy laravel project.
  COPY --from=vendor /app /app
  </code></pre>