Reputation: 4229
Creating a new docker image from a container is done with the following syntax:
$ docker commit -m "commit message" -a "author" \
#containerid user/imagename:tag
I know you can get the last container id from:
$ docker ps -l
But that gives me verbose output. How can I regex the container id or input a command to extract just the last container id so that I don't have to manually type it into my commit message?
Upvotes: 0
Views: 86
Reputation: 4229
I found the answer and thought I'd post it in case someone else runs into the same issue:
$ sudo docker commit -m "commit message" -a "author" \
$(sudo docker ps -lq) user/imagename:tag
You use docker ps -lq
Upvotes: 1