Is it possible to re-create or re-deploy docker container with same container ID?

Viewed 466

I am storing container ID in my database, based on that I regularly check if my container is still running or has stopped using 'Docker Inspect' I update this info in my database.

The above method is fine if I only want to update the status but if someone wants to change the env. variables and use the docker run command to create the container then a new container ID gets generated.

So my question is if it is possible to generate the new docker container with the container Id it had previously?

1 Answers

It looks like there is no option to "manually" set a UUID when you run a container. This is something that the Docker Daemon takes care of.

Container identification

The operator can identify a container in three ways:

| Identifier type       |                              Example value                        |
|===========================================================================================|
| UUID long identifier  | "f78375b1c487e03c9438c729345e54db9d20cfa2ac1fc3494b6eb60872e74778"|
| UUID short identifier | "f78375b1c487"                                                    |
| Name                  | "evil_ptolemy"                                                    |

The UUID identifiers come from the Docker daemon. If you do not assign a container name with the --name option, then the daemon generates a random string name for you. Defining a name can be a handy way to add meaning to a container. If you specify a name, you can use it when referencing the container within a Docker network. This works for both background and foreground Docker containers.

Related