I tried to provison a basic Docker instance
{
"type": "docker",
"image": "tianon/centos:6.5",
"export_path": "vm.tar",
"run_command": ["run", "-m=8g","-c=0","-d", "-i", "-t", "-v", "{{.Volumes}}", "{{.Image}}", "/bin/bash"]
}
A shell script provision that I had failed and it resulted in an error like this:
docker: Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os error was
docker: 14: PYCURL ERROR 6 - "Couldn't resolve host 'mirrorlist.centos.org'"
==> docker: Killing the container: 200d89e0dce6770146b30d978a2040c5ec28c579de0f04bd812241bc2ff0033
if you do a 'docker ps' it comes empty, that container is not running.
but if you try to remove the actual image (tianon/centos:6.5) it complains that it cannot since it is used by container "200d89e0dce6770146b30d978a2040c5ec28c579de0f04bd812241bc2ff0033",
If seems that in case of an error Packer should not only kill the container, but automatically remove it as well, so a "docker rm
Otherwise the user may get left with a lot of containers defined (once every failed run) which then have to be removed manually one by one in case of any required cleanup.
Agreed. Thanks.
Potentially a simple fix maybe to run the container with '--rm=true'. that may take care of it automatically.
--rm=false: Automatically remove the container when it exits (incompatible with -d)
Fixed.
@mitchellh
Is there some arguments that I can remain the running container. I want to attach to the container and find out what's wrong on earth. If it was killed, I can only get the error without any context. Thanks in advance.
Most helpful comment
@mitchellh
Is there some arguments that I can remain the running container. I want to attach to the container and find out what's wrong on earth. If it was killed, I can only get the error without any context. Thanks in advance.