1:通过tar 备份目录
tar -cvpf /home/ --directory=/ --exclude=proc --exclude=sys --exclude=dev --exclude=run /
[root@localhost home]# ls
2:导入镜像
cat | docker import - buildrpm。
如果提示Cannot connect to the Docker daemon at unix:///var/run/. Is the docker daemon running?
则先运行docker service
[root@localhost home]# service docker start
3:运行
[root@localhost home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
buildrpm latest 15adc9614eb8 17 seconds ago 1.14 GB
[root@localhost home]# docker run -it buildrpm:latest /bin/bash
4删除:
[root@localhost 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
[root@localhost home]# docker rm 920f5a69f58d
920f5a69f58d
[root@localhost home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
buildrpm latest 15adc9614eb8 4 minutes ago 1.14 GB
[root@localhost home]# docker rmi 15adc9614eb8
Untagged: buildrpm:latest
Deleted: sha256:15adc9614eb815974edfaca89671f86ea61e46929792c42f7515dfd65ff24688
Deleted: sha256:aed61d9930e43fbf0c5d3a771b9dde602b0dda2fec6066a166d2ba9180402880
[root@localhost home]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE