I'm learning docker 1.8. I wanted to change the hostname of the container after I create them. I tried to edit /etc/host inside the container and got overwritten every time I attach then start the image. I tried to edit the following file, and the hostname gets overwritten.
I am not sure if you mean you want to set the hostname of a new container or of a running container. You say you want to do it after creating the container, but then you also say you're "starting the image". If you haven't started the image you haven't yet created the container -- a container is what you get when you start an image.
This is more difficult. You'll want to keep an eye on this Docker issue but until it's resolved you can't do much more than to edit /etc/hosts I think. The hostname command won't work.