基於當前系統製作docker映象
阿新 • • 發佈:2018-11-23
1:通過tar 備份目錄
tar -cvpf /home/buildrpm.tar --directory=/ --exclude=proc --exclude=sys --exclude=dev --exclude=run /
[[email protected] home]# ls
buildrpm.tar
2:匯入映象
cat buildrpm.tar | docker import - buildrpm。
如果提示Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
則先執行docker service
[ [email protected] home]# service docker start
3:執行
[[email protected] home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
buildrpm latest 15adc9614eb8 17 seconds ago 1.14 GB
[[email protected] home]# docker run -it buildrpm:latest /bin/bash
4刪除:
[ [email protected] home]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
920f5a69f58d buildrpm:latest "/bin/bash" 2 minutes ago Exited (0) 2 minutes ago laughing_minsky
[ [email protected] home]# docker rm 920f5a69f58d
920f5a69f58d
[[email protected] home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
buildrpm latest 15adc9614eb8 4 minutes ago 1.14 GB
[[email protected] home]# docker rmi 15adc9614eb8
Untagged: buildrpm:latest
Deleted: sha256:15adc9614eb815974edfaca89671f86ea61e46929792c42f7515dfd65ff24688
Deleted: sha256:aed61d9930e43fbf0c5d3a771b9dde602b0dda2fec6066a166d2ba9180402880
[[email protected] home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE