Skip to content

Instantly share code, notes, and snippets.

@pingkunga
Created May 26, 2024 08:53
Show Gist options
  • Save pingkunga/60d47a503af1c2aad611b31af34a9d98 to your computer and use it in GitHub Desktop.
Save pingkunga/60d47a503af1c2aad611b31af34a9d98 to your computer and use it in GitHub Desktop.
docker update command sample

Update a container’s cpu-shares

docker update --cpu-shares 512 abebf7571666

Update a container with cpu-shares and memory

docker update --cpu-shares 512 -m 300M abebf7571666 hopeful_morse

Update a new container’s kernel memory constraints

docker run -dit --name test --kernel-memory 50M ubuntu bash

Update kernel memory while the container is running:

docker update --kernel-memory 80M test

Started a container without kernel memory initialized:

docker run -dit --name test2 --memory 300M ubuntu bash

To update restart policy for one or more containers:

docker update --restart=on-failure:3 abebf7571666 hopeful_morse

Add a restart policy to a container that was already created

docker update --restart=always <container>

Update the "RunningContainerNameOrId" to use 1g of memory and only use cpu core 1

docker update --memory "1g" --cpuset-cpu "1" <RunningContainerNameOrID>

To up date all running containers to use core 1 and 1g of memory:

docker update --cpuset-cpus "1" --memory "1g" $(docker ps | awk 'NR>1 {print $1}')

Disable auto-restart on a container?

docker update --restart=no my-container
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment