Remove a Docker Swarm config by ID
In this step, we will learn how to remove a Docker Swarm config using its ID. While removing by name is often more convenient, removing by ID is useful when you have multiple configs with similar names or need to be absolutely sure which config you are removing.
First, let's create another config so we have something to remove by ID. We'll create a file named another_config.txt
and then create a config from it.
echo "This is another sample configuration data." > ~/project/another_config.txt
docker config create another_app_config ~/project/another_config.txt
Now, list the configs to get the ID of another_app_config
.
docker config ls
Look for the another_app_config
in the output and note its ID. The ID will be a string of characters.
To remove a Docker Swarm config by its ID, you use the docker config rm
command followed by the ID of the config. The syntax is docker config rm <config_id>
.
Replace <config_id>
with the actual ID you noted from the previous command's output.
docker config rm <config_id>
For example, if the ID was abcdef123456
, the command would be:
docker config rm abcdef123456
You should see the ID of the removed config in the output, confirming its removal.
Finally, list the configs again to verify that another_app_config
is no longer present.
docker config ls