github.com/kobeld/docker@v1.12.0-rc1/docs/reference/commandline/commit.md (about)

     1  <!--[metadata]>
     2  +++
     3  title = "commit"
     4  description = "The commit command description and usage"
     5  keywords = ["commit, file, changes"]
     6  [menu.main]
     7  parent = "smn_cli"
     8  +++
     9  <![end-metadata]-->
    10  
    11  # commit
    12  
    13      Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
    14  
    15      Create a new image from a container's changes
    16  
    17        -a, --author=""     Author (e.g., "John Hannibal Smith <hannibal@a-team.com>")
    18        -c, --change=[]     Apply specified Dockerfile instructions while committing the image
    19        --help              Print usage
    20        -m, --message=""    Commit message
    21        -p, --pause=true    Pause container during commit
    22  
    23  It can be useful to commit a container's file changes or settings into a new
    24  image. This allows you debug a container by running an interactive shell, or to
    25  export a working dataset to another server. Generally, it is better to use
    26  Dockerfiles to manage your images in a documented and maintainable way.
    27  [Read more about valid image names and tags](tag.md).
    28  
    29  The commit operation will not include any data contained in
    30  volumes mounted inside the container.
    31  
    32  By default, the container being committed and its processes will be paused
    33  while the image is committed. This reduces the likelihood of encountering data
    34  corruption during the process of creating the commit.  If this behavior is
    35  undesired, set the `--pause` option to false.
    36  
    37  The `--change` option will apply `Dockerfile` instructions to the image that is
    38  created.  Supported `Dockerfile` instructions:
    39  `CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`LABEL`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR`
    40  
    41  ## Commit a container
    42  
    43      $ docker ps
    44      ID                  IMAGE               COMMAND             CREATED             STATUS              PORTS
    45      c3f279d17e0a        ubuntu:12.04        /bin/bash           7 days ago          Up 25 hours
    46      197387f1b436        ubuntu:12.04        /bin/bash           7 days ago          Up 25 hours
    47      $ docker commit c3f279d17e0a  svendowideit/testimage:version3
    48      f5283438590d
    49      $ docker images
    50      REPOSITORY                        TAG                 ID                  CREATED             SIZE
    51      svendowideit/testimage            version3            f5283438590d        16 seconds ago      335.7 MB
    52  
    53  ## Commit a container with new configurations
    54  
    55      $ docker ps
    56      ID                  IMAGE               COMMAND             CREATED             STATUS              PORTS
    57      c3f279d17e0a        ubuntu:12.04        /bin/bash           7 days ago          Up 25 hours
    58      197387f1b436        ubuntu:12.04        /bin/bash           7 days ago          Up 25 hours
    59      $ docker inspect -f "{{ .Config.Env }}" c3f279d17e0a
    60      [HOME=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin]
    61      $ docker commit --change "ENV DEBUG true" c3f279d17e0a  svendowideit/testimage:version3
    62      f5283438590d
    63      $ docker inspect -f "{{ .Config.Env }}" f5283438590d
    64      [HOME=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin DEBUG=true]
    65  
    66  ## Commit a container with new `CMD` and `EXPOSE` instructions 
    67  
    68      $ docker ps
    69      ID                  IMAGE               COMMAND             CREATED             STATUS              PORTS
    70      c3f279d17e0a        ubuntu:12.04        /bin/bash           7 days ago          Up 25 hours
    71      197387f1b436        ubuntu:12.04        /bin/bash           7 days ago          Up 25 hours
    72  
    73      $ docker commit --change='CMD ["apachectl", "-DFOREGROUND"]' -c "EXPOSE 80" c3f279d17e0a  svendowideit/testimage:version4
    74      f5283438590d
    75      
    76      $ docker run -d svendowideit/testimage:version4
    77      89373736e2e7f00bc149bd783073ac43d0507da250e999f3f1036e0db60817c0
    78  
    79      $ docker ps
    80      ID                  IMAGE               COMMAND                 CREATED             STATUS              PORTS
    81      89373736e2e7        testimage:version4  "apachectl -DFOREGROU"  3 seconds ago       Up 2 seconds        80/tcp
    82      c3f279d17e0a        ubuntu:12.04        /bin/bash               7 days ago          Up 25 hours
    83      197387f1b436        ubuntu:12.04        /bin/bash               7 days ago          Up 25 hours