Published 5月 27, 2019 by with 0 comment

2 - 02 - Build a Image (Docker commit)




There are two ways to build image, Docker commit and Dockerfile (recommendation).
In this lab, I will study to use Docker commit to build a image.
First, pull a ubuntu image from Docker Hub.
This image will not include vim.
I will install vim and then build a new image called ubuntu-vi.

1. Download a ubuntu image from Docker Hub
$ docker pull ubuntu



2. Verify
$ docker images ubuntu 



3. Run this image.
$ docker run -it ubuntu



4. Make sure this image has not vim
# vim



5. Install vim
# apt-get update
# apt-get install -y apt-file
# apt-file update
# apt-get install -y vim


6. Open another terminal and check the container process. Ths name is called kind_mirzakhani.
$ docker ps



7. Using the docker commit to build a new image called ubuntu-vi
$ docker commit kind_mirzakhani ubuntu-vi



8. Check docker image, I found a new image ubuntu-vi
$ docker image ls



9. In the second terminal, let us run the new image and check vim is working.
$ docker run -it ubuntu-vi
# which vim



10. Using docker history to analyse the ubuntu-vi.
$ docker history  ubuntu-vi:latest




最初發表 / 最後更新: 2019.05.27 / 2019.05.27

0 comments:

張貼留言