Updating a restart policy on a running container

Sometimes, there's a need to update the Docker runtime parameters after the container has already started, on the fly. An example would be if you want to prevent containers from consuming too many resources on the Docker host. To set the policy during runtime, we can use the docker update command. Apart from other runtime parameters (such as memory or CPU constraints for example, which we are going to discuss later in this chapter), the docker update command gives you the option to update the restart policy on a running container. The syntax is quite straightforward, you just need to provide the new restart policy that you would like the container to have and the container's ID or name:

$ docker ...

Get Docker and Kubernetes for Java Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.