@@ -9,10 +9,6 @@ long: |-
99 (root). If you specify an individual file, you must specify the full path within
1010 the host. To import from a remote location, specify a `URI` that begins with the
1111 `http://` or `https://` protocol.
12-
13- The `--change` option applies `Dockerfile` instructions to the image that is
14- created. Supported `Dockerfile` instructions:
15- `CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR`
1612usage : docker image import [OPTIONS] file|URL|- [REPOSITORY[:TAG]]
1713pname : docker image
1814plink : docker_image.yaml
@@ -21,6 +17,7 @@ options:
2117 shorthand : c
2218 value_type : list
2319 description : Apply Dockerfile instruction to the created image
20+ details_url : ' #change'
2421 deprecated : false
2522 hidden : false
2623 experimental : false
@@ -31,6 +28,7 @@ options:
3128 shorthand : m
3229 value_type : string
3330 description : Set commit message for imported image
31+ details_url : ' #message'
3432 deprecated : false
3533 hidden : false
3634 experimental : false
@@ -40,6 +38,7 @@ options:
4038 - option : platform
4139 value_type : string
4240 description : Set platform if server is multi-platform capable
41+ details_url : ' #platform'
4342 deprecated : false
4443 hidden : false
4544 min_api_version : " 1.32"
@@ -75,12 +74,6 @@ examples: |-
7574 $ cat exampleimage.tgz | docker import - exampleimagelocal:new
7675 ```
7776
78- Import with a commit message.
79-
80- ```console
81- $ cat exampleimage.tgz | docker import --message "New image imported from tarball" - exampleimagelocal:new
82- ```
83-
8477 Import to docker from a local archive.
8578
8679 ```console
@@ -93,16 +86,109 @@ examples: |-
9386 $ sudo tar -c . | docker import - exampleimagedir
9487 ```
9588
96- ### Import from a local directory with new configurations
97-
98- ```console
99- $ sudo tar -c . | docker import --change "ENV DEBUG=true" - exampleimagedir
100- ```
101-
10289 Note the `sudo` in this example – you must preserve
10390 the ownership of the files (especially root ownership) during the
10491 archiving with tar. If you are not root (or the sudo command) when you
10592 tar, then the ownerships might not get preserved.
93+
94+ ### Import with new configurations (-c, --change) {#change}
95+
96+ The `--change` option applies `Dockerfile` instructions to the image that is
97+ created. Not all `Dockerfile` instructions are supported; the list of instructions
98+ is limited to metadata (configuration) changes. The following `Dockerfile`
99+ instructions are supported:
100+
101+ - [`CMD`](/reference/dockerfile/#cmd)
102+ - [`ENTRYPOINT`](/reference/dockerfile/#entrypoint)
103+ - [`ENV`](/reference/dockerfile/#env)
104+ - [`EXPOSE`](/reference/dockerfile/#expose)
105+ - [`HEALTHCHECK`](/reference/dockerfile/#healthcheck)
106+ - [`LABEL`](/reference/dockerfile/#label)
107+ - [`ONBUILD`](/reference/dockerfile/#onbuild)
108+ - [`STOPSIGNAL`](/reference/dockerfile/#stopsignal)
109+ - [`USER`](/reference/dockerfile/#user)
110+ - [`VOLUME`](/reference/dockerfile/#volume)
111+ - [`WORKDIR`](/reference/dockerfile/#workdir)
112+
113+ The following example imports an image from a TAR-file containing a root-filesystem,
114+ and sets the `DEBUG` environment-variable in the resulting image:
115+
116+ ```console
117+ $ docker import --change "ENV DEBUG=true" ./rootfs.tgz exampleimagedir
118+ ```
119+
120+ The `--change` option can be set multiple times to apply multiple `Dockerfile`
121+ instructions. The example below sets the `LABEL1` and `LABEL2` labels on
122+ the imported image, in addition to the `DEBUG` environment variable from
123+ the previous example:
124+
125+ ```console
126+ $ docker import \
127+ --change "ENV DEBUG=true" \
128+ --change "LABEL LABEL1=hello" \
129+ --change "LABEL LABEL2=world" \
130+ ./rootfs.tgz exampleimagedir
131+ ```
132+
133+ ### Import with a commit message (-m, --message) {#message}
134+
135+ The `--message` (or `-m`) option allows you to set a custom comment in
136+ the image's metadata. The following example imports an image from a local
137+ archive and sets a custom message.
138+
139+ ```console
140+ $ docker import --message "New image imported from tarball" ./rootfs.tgz exampleimagelocal:new
141+ sha256:25e54c0df7dc49da9093d50541e0ed4508a6b78705057f1a9bebf1d564e2cb00
142+ ```
143+
144+ After importing, the message is set in the "Comment" field of the image's
145+ configuration, which is shown when viewing the image's history:
146+
147+ ```console
148+ $ docker image history exampleimagelocal:new
149+
150+ IMAGE CREATED CREATED BY SIZE COMMENT
151+ 25e54c0df7dc 2 minutes ago 53.6MB New image imported from tarball
152+ ```
153+
154+ ### When the daemon supports multiple operating systems
155+
156+ If the daemon supports multiple operating systems, and the image being imported
157+ does not match the default operating system, it may be necessary to add
158+ `--platform`. This would be necessary when importing a Linux image into a Windows
159+ daemon.
160+
161+ ```console
162+ $ docker import --platform=linux .\linuximage.tar
163+ ```
164+
165+ ### Set the platform for the imported image (--platform) {#platform}
166+
167+ The `--platform` option allows you to specify the platform for the imported
168+ image. By default, the daemon's native platform is used as platform, but
169+ the `--platform` option allows you to override the default, for example, in
170+ situations where the imported root filesystem is for a different architecture
171+ or operating system.
172+
173+ The platform option takes the `os[/arch[/variant]]` format; for example,
174+ `linux/amd64` or `linux/arm64/v8`. Architecture and variant are optional,
175+ and default to the daemon's native architecture if omitted.
176+
177+ The following example imports an image from a root-filesystem in `rootfs.tgz`,
178+ and sets the image's platform to `linux/amd64`;
179+
180+ ```console
181+ $ docker image import --platform=linux/amd64 ./rootfs.tgz imported:latest
182+ sha256:44a8b44157dad5edcff85f0c93a3e455f3b20a046d025af4ec50ed990d7ebc09
183+ ```
184+
185+ After importing the image, the image's platform is set in the image's
186+ configuration;
187+
188+ ```console
189+ $ docker image inspect --format '{{.Os}}/{{.Architecture}}' imported:latest
190+ linux/amd64
191+ ```
106192deprecated : false
107193hidden : false
108194experimental : false
0 commit comments