Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

Docker and application updates

Hello,

I have dockerized a Laravel application.

This application runs on a demo server and I regularly add new features and updates without restarting the entire docker containers.

This doesn't seem to be a problem.

But are there some updates for which it's necessary to restart the docker containers so that the updates are taken into account ?

Thanks for your answer.

V

1 like
3 replies
LaryAI's avatar
Level 58

Certainly! When working with Dockerized applications, there are specific scenarios where restarting the Docker containers is necessary to ensure that updates are properly applied. Here are some common situations where a restart might be required:

  1. Changes to Dockerfile: If you make changes to the Dockerfile, such as installing new dependencies or modifying environment variables, you will need to rebuild the image and restart the container to apply these changes.

  2. Changes to docker-compose.yml: If you modify the docker-compose.yml file, such as adding new services, changing volumes, or updating environment variables, you will need to restart the containers to apply these changes.

  3. Updates to Environment Variables: If your application relies on environment variables and you change them, you will need to restart the container to load the new environment variables.

  4. Updates to Configuration Files: If your application uses configuration files that are loaded at startup (e.g., config/app.php in Laravel), you may need to restart the container to apply changes to these files.

  5. Dependency Updates: If you update dependencies (e.g., via composer update for PHP or npm install for Node.js), you might need to restart the container to ensure that the application is using the updated dependencies.

  6. Code Changes: For some code changes, especially those that affect the application startup process, you might need to restart the container. However, for most code changes, you can simply copy the updated files into the running container.

Here is an example of how you can rebuild and restart your Docker containers using Docker Compose:

# Rebuild the Docker images
docker-compose build

# Restart the Docker containers
docker-compose up -d

If you only need to restart a specific service, you can do so with:

# Restart a specific service
docker-compose restart <service_name>

For example, if your service is named app, you would run:

docker-compose restart app

In summary, while many updates can be applied without restarting the Docker containers, certain changes, especially those related to the Docker configuration, environment variables, and dependencies, will require a restart to take effect.

MohamedTammam's avatar
Level 51

But are there some updates for which it's necessary to restart the docker containers so that the updates are taken into account ?

  1. If you install new package.
  2. if you want to rebuilt assets
  3. If you modify part of the code that effect running jobs.
  4. If you modify docker container itself.
  5. ...

for 1 and 2 I'm assuming that these processes are in the container build script.

1 like

Please or to participate in this conversation.