DigiLord
DigiLord

Reputation: 1014

How to copy and rename a Docker container?

I have a docker container that I want to use to partition client access to a database. I'd like to be able to have one container per client. If I start multiple copies of the container they all have the same name, the only difference being the port the container is assigned to.

How can I copy/rename the containers in such a way that I can differentiate the container without having to consult a lookup table that matches the assigned port to the client?

Upvotes: 26

Views: 28387

Answers (3)

SergiiKozlov
SergiiKozlov

Reputation: 831

The docker rename command is part of Docker 1.5. Link to commit: docker github

Upvotes: 32

pward123
pward123

Reputation: 734

I'm using docker 1.0.1 and the following allows me to rename an image:

docker tag 1cf76 myUserName/imageName:0.1.0

Upvotes: 17

creack
creack

Reputation: 121442

All containers have a uniq name. When you do docker ps You can see that the first column is the ID. You can then manipulate your containers with this ID.

You actually need this ID in order to perform any operation on the container (stop/start/inspect/etc..)

I am unsure of what you are trying to do, but for each client, you can start a new container and then link the container ID with your user ID.

At the moment, there is no container naming within Docker, so you can't name nor rename a container, you only can use its ID.

In future versions, naming for container will be implemented.

Upvotes: 7

Related Questions