I've build a docker container from a dockerscript, e.g.
user@servername:~$ echo "FROM ubuntu:latest" > dscript.txt
user@servername:~$
user@servername:~$ cat dscript.txt
FROM ubuntu:latest
user@servername:~$ docker build -t ubu.image - < dscript.txt
Sending build context to Docker daemon 2.048kB
Step 1/1 : FROM ubuntu:latest
---> 0ef2e08ed3fa
Successfully built 0ef2e08ed3fa
And I can run it by using the image name I've given, i.e. ubu.image
:
user@servername:~$ docker run -it ubu.image
root@c00379445b9d:/# exit
exit
user@servername:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
user@servername:~$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
But to export it I have to use the commit hash:
user@servername:~$ docker export c00379445b9d > ubu.image.tar
I've tried using the container name instead of the hash but it throws an error:
$ docker export ubu.image > ubu.image.tar
Error response from daemon: No such container: ubu.image
The question is:
Is there a way to find out the latest commit hash of the container that's needed to export the container as a
.tar
file?Without the latest commit hash, is it possible to export the container as
.tar
file? Is so, how?