lunes, 16 de septiembre de 2024

How to Create a Docker Image From a Container: docker commit

Let’s say you want a commit message to remind yourself what the image is about or what the state of the container was at the time the image was made.

There is a –message option you can use to include that information. Then with docker history you can change the messages. Look at this example.

 

[root@ip-172-31-32-118 ~]# docker image list

REPOSITORY   TAG       IMAGE ID       CREATED        SIZE

node-app     1.2       65c5722fd8ec   24 hours ago   184MB

node-app     1.1       eaadab861a02   24 hours ago   184MB

node-app     1.0       f807c87a32a0   27 hours ago   184MB


[root@ip-172-31-32-118 ~]# docker ps -a

CONTAINER ID   IMAGE          COMMAND                  CREATED        STATUS                      PORTS     NAMES

3b3cb2148dca   node-app:1.2   "docker-entrypoint.s…"   24 hours ago   Exited (137) 10 hours ago             stoic_gould

5d323066f95f   node-app:1.1   "docker-entrypoint.s…"   24 hours ago   Exited (137) 24 hours ago             naughty_turing





We execute docker commit, with the containerID and then the tag of the new image:

[root@ip-172-31-32-118 ~]# docker commit --message 'this is a basic node image change' 3b3cb2148dca node-app:1.3


sha256:7db963f345124cce27bf29b8b8314fb1d592ab6b05809221d13d2a259a7ede7f

[root@ip-172-31-32-118 ~]# docker image list

REPOSITORY   TAG       IMAGE ID       CREATED         SIZE

node-app     1.3       7db963f34512   6 seconds ago   184MB

node-app     1.2       65c5722fd8ec   24 hours ago    184MB

node-app     1.1       eaadab861a02   24 hours ago    184MB

node-app     1.0       f807c87a32a0   27 hours ago    184MB


[root@ip-172-31-32-118 ~]# docker history 7db963f34512

IMAGE          CREATED              CREATED BY                                      SIZE      COMMENT

7db963f34512   About a minute ago   node server.js                                  235B      this is a basic node image change

65c5722fd8ec   24 hours ago         node server.js                                  0B        

eaadab861a02   24 hours ago         CMD ["node" "server.js"]                        0B        buildkit.dockerfile.v0

<missing>      24 hours ago         RUN /bin/sh -c npm install # buildkit           6.84MB    buildkit.dockerfile.v0

<missing>      24 hours ago         WORKDIR /app                                    0B        buildkit.dockerfile.v0

<missing>      24 hours ago         COPY src /app/ # buildkit                       225B      buildkit.dockerfile.v0

<missing>      27 hours ago         COPY package.json /app/ # buildkit              114B      buildkit.dockerfile.v0

<missing>      15 months ago        /bin/sh -c #(nop)  CMD ["node"]                 0B        

<missing>      15 months ago        /bin/sh -c #(nop)  ENTRYPOINT ["docker-entry…   0B        

<missing>      15 months ago        /bin/sh -c #(nop) COPY file:4d192565a7220e13…   388B      

<missing>      15 months ago        /bin/sh -c apk add --no-cache --virtual .bui…   7.76MB    

<missing>      15 months ago        /bin/sh -c #(nop)  ENV YARN_VERSION=1.22.19     0B        

<missing>      15 months ago        /bin/sh -c addgroup -g 1000 node     && addu…   162MB     

<missing>      15 months ago        /bin/sh -c #(nop)  ENV NODE_VERSION=19.9.0      0B        

<missing>      16 months ago        /bin/sh -c #(nop)  CMD ["/bin/sh"]              0B        

<missing>      16 months ago        /bin/sh -c #(nop) ADD file:7625ddfd589fb824e…   7.33MB 

No hay comentarios:

Publicar un comentario