基于当前系统制作docker镜像

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/tiantao2012/article/details/82425660
1:通过tar 备份目录
tar -cvpf /home/buildrpm.tar --directory=/ --exclude=proc --exclude=sys --exclude=dev --exclude=run /
[root@localhost 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
[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

猜你喜欢

转载自blog.csdn.net/tiantao2012/article/details/82425660