github.com/olljanat/moby@v1.13.1/docs/reference/commandline/commit.md (about)

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