Linux文件系统由bootfs和rootfs两部分组成。
docker commit 容器id 镜像名称:版本号 # 把容器转为镜像
docker save -o 压缩文件名称 镜像名称:版本号 # 把镜像压缩成可传输文件
docker load -i 压缩文件名 # 把压缩文件加载为镜像
示例:
[root@master data]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
483af2bd8131 httputils-docker:test "java -jar /httpUtil…" 8 months ago Up 26 minutes 8097/tcp, 0.0.0.0:8090->8080/tcp, :::8090->8080/tcp httpUtil-test
[root@master data]# docker commit 483af2bd8131 new-http-util:1.0
sha256:6eb8bae514fce2af996eb8889c7ec6c93f134083f7d6a17c5ac38ea5fb040875
[root@master data]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
new-http-util 1.0 6eb8bae514fc 8 seconds ago 125MB
[root@master data]# docker save -o new-http-util.tar new-http-util:1.0
[root@master data]# ll
total 123068
drwxr-xr-x 4 root root 4096 Jul 7 22:27 con1
-rw------- 1 root root 126007296 Aug 30 23:44 new-http-util.tar
drwxr-xr-x 4 root root 4096 Jul 7 22:28 s1
drwxr-xr-x 4 root root 4096 Jul 7 22:28 s2
[root@master data]# docker rmi 6eb8bae514fc
Untagged: new-http-util:1.0
Deleted: sha256:6eb8bae514fce2af996eb8889c7ec6c93f134083f7d6a17c5ac38ea5fb040875
Deleted: sha256:dcc4adf8d521ab5f2993f5724d6bdfdadc613db2f4ed78396b992d3cc84848e9
[root@master data]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
[root@master data]# docker load -i new-http-util.tar
41b9fc9e3b47: Loading layer [==================================================>] 43.01kB/43.01kB
Loaded image: new-http-util:1.0
[root@master data]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
new-http-util 1.0 6eb8bae514fc About a minute ago 125MB
[root@master data]#
定义dockerfile,发布springboot项目。
FROM java:8
MAINTAINER xiaomin
ADD springboot-hello-0.0.0.1-SNAPSHOT.jar app.jar
CMD java -jar app.jar
docker build -f ./springboot_dockerfile -t app .
docker images
docker run --name=hellowold-test -id -p 8080:8080 app
docker ps