Docker Config Reference (docker commit)
Docker Config Super Reference (docker commit)
Example 1
docker commit myrunningcontainer newimage:latest
This command generates a new image tagged "newimage:latest" from the current state of the running container "myrunningcontainer". It captures all filesystem modifications since the container's inception, facilitating the preservation of runtime alterations for subsequent deployments.
Example 2
docker commit --pause=false debugcont snapshot:dev
This command commits the container "debugcont" to an image "snapshot:dev" without pausing the container during the process, allowing continuous operation while creating a live snapshot for debugging purposes in active environments.
Example 3
docker commit --author="Developer Name <dev@example.com>" appcontainer appimage:1.0
This command creates "appimage:1.0" from "appcontainer", attributing the changes to the specified author, which is useful for maintaining version history and accountability in collaborative development workflows.
Example 4
docker commit --message="Added configuration files" configcont updatedconfig:latest
This command commits "configcont" to "updatedconfig:latest" with a descriptive commit message, akin to version control practices, aiding in tracking specific modifications like file additions.
Example 5
docker commit --change='CMD ["nginx", "-g", "daemon off;"]' webcont nginxcustom:stable
This command alters the default command in the new image "nginxcustom:stable" from "webcont" by specifying a CHANGE directive, customizing runtime behavior for web server applications.
Example 6
docker commit --change='EXPOSE 8080' portcont exposedimage:1.2
This command commits "portcont" to "exposedimage:1.2", adding an EXPOSE instruction to document port 8080, enhancing image metadata for networked services.
Example 7
docker commit --change='ENV APP_ENV=production' envcont prodimage:latest
This command sets an environment variable in the committed image "prodimage:latest" from "envcont", configuring production-specific settings during image creation.
Example 8
docker commit --pause=true pausedcont frozenstate:debug
This command pauses "pausedcont" temporarily to commit a consistent state to "frozenstate:debug", ensuring data integrity for debugging intermittent issues.
Example 9
docker commit a1b2c3d4e5f6 quicksave:latest
This command commits a container identified by its partial ID "a1b2c3d4e5f6" to "quicksave:latest", providing flexibility when container names are not readily available.
Example 10
docker commit --author="Team Lead" --message="Security patches applied" securecont patched:secure
This command combines author and message options for "securecont" to create "patched:secure", documenting security updates for compliance and audit trails.
Example 11
docker commit --change='ENTRYPOINT ["/app/entry.sh"]' entrycont customentry:1.3
This command modifies the entrypoint in "customentry:1.3" from "entrycont", tailoring startup scripts for specialized application launches.
Example 12
docker commit --change='LABEL version="2.0"' labelcont versioned:2.0
This command adds a label to "versioned:2.0" from "labelcont", facilitating image filtering and management in registries.
Example 13
docker commit --change='USER appuser' usercont nonroot:latest
This command switches the default user in "nonroot:latest" from "usercont" to "appuser", enhancing security by avoiding root privileges in runtime.
Example 14
docker commit --change='VOLUME /data' volcont persistent:dev
This command declares a volume in "persistent:dev" from "volcont", promoting data persistence across container lifecycles.
Example 15
docker commit --change='WORKDIR /app' workcont appdir:stable
This command sets the working directory in "appdir:stable" from "workcont", standardizing file paths for application consistency.
Example 16
docker commit --pause=false --message="Live commit during load test" loadtestcont testimage:load
This command commits "loadtestcont" without pausing, with a message, for capturing states during performance testing.
Example 17
docker commit --author="QA Team" qaenvcont qaimage:tested
This command attributes the commit of "qaenvcont" to the QA team for "qaimage:tested", supporting quality assurance processes.
Example 18
docker commit --change='CMD ["python", "script.py"]' scriptcont pythonimage:exec
This command customizes the command for "pythonimage:exec" from "scriptcont", adapting for script-based executions.
Example 19
docker commit --change='EXPOSE 443' secureportcont httpsimage:secure
This command exposes port 443 in "httpsimage:secure" from "secureportcont", preparing for secure communications.
Example 20
docker commit --message="Installed additional dependencies" depcont extended:deps
This command documents dependency installations in "extended:deps" from "depcont", aiding maintenance.
Example 21
docker commit --change='ENV DEBUG=true' debugcont debugmode:enabled
This command enables debug mode via environment variable in "debugmode:enabled" from "debugcont".
Example 22
docker commit --pause=true dataconsistcont consistentdata:snapshot
This command ensures consistency by pausing "dataconsistcont" for "consistentdata:snapshot".
Example 23
docker commit f6e5d4c3b2a1 idbased:latest
This command uses a full container ID for committing to "idbased:latest", for precise referencing.
Example 24
docker commit --author="Admin" --change='LABEL maintainer="admin@example.com"' maintcont maintained:1.4
This command adds maintainer label and author for "maintained:1.4" from "maintcont".
Example 25
docker commit --change='ENTRYPOINT ["bash"]' shellcont bashimage:shell
This command sets bash as entrypoint in "bashimage:shell" from "shellcont", for interactive shells.
Example 26
docker commit --message="Configuration optimized" optcont optimized:config
This command notes optimizations in "optimized:config" from "optcont".
Example 27
docker commit --change='USER nobody' nobodycont minimalpriv:least
This command uses minimal privileges in "minimalpriv:least" from "nobodycont".
Example 28
docker commit --change='VOLUME /logs' logcont logged:persistent
This command declares a log volume in "logged:persistent" from "logcont".
Example 29
docker commit --pause=false --author="DevOps" opscont opsimage:managed
This command commits live with author for "opsimage:managed" from "opscont".
Example 30
docker commit --change='WORKDIR /data' --message="Data directory set" datacont dataimage:structured
This command combines workdir change and message for "dataimage:structured" from "datacont".