Docker – How to name a docker container

dockerubuntu-12.04

On Ubuntu 12.04.4 I installed Docker 1.1.2. I have tried various attempts at setting the image id using:

sudo docker run -i -t --name=container1 ubuntu date

However, my attempts seem to fail. Every time I do a docker ps -a the image id has been randomized. I can set the hostname if I add -h container1 but I want to set the image id. What am I missing here? Thanks!

Best Answer

Sorry for the late response, I'm on version 1.1.2 myself now and the correct way of naming your container is as follows:

sudo docker run --name="testname" image command

testname is the name you want to give the container.

Have fun dockering!