How to Modify the Configuration for Running Docker Containers

insert image description here
Docker containers are generally considered immutable once they start running. However, you can dynamically update some configuration parameters, such as the container's name and its hardware resource limits.

In this guide, we'll show you how to use the built-in Docker commands to modify selected parameters of a running container. We'll also look at what you shouldn't change and what workarounds you can use if you think you must.

Heavy naming container

The simplest modification is to rename the created container. The --name name is assigned via the flag for docker run. If no name is provided, the Docker daemon will assign a random name. You can refer to containers by name in Docker CLI commands; choose a suitable memorable one to avoid running docker ps to find a container's auto-assigned name or ID.

The docker rename command is used to change the container name after creation. It takes two parameters, the ID or current name of the target container, and a new name to assign:

# docker rename <target ID or name> <new name>
docker rename old_name new_name

Change restart policy

The restart policy determines whether the container should start automatically after a host restart or after the Docker daemon starts

Guess you like

Origin blog.csdn.net/wlcs_6305/article/details/123294969