Skip to content

Commit 7920728

Browse files
committed
docs: import: fix anchor-links and minor touch-up
- Put the content related to `--changes` under a heading with the correct anchor, so that it will be linked from the "options" table. - Move note about `sudo` to be under the right example. - Update some examples to directly read from a file instead of piping. - Add heading for the `--message` flag. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 25a1681 commit 7920728

1 file changed

Lines changed: 49 additions & 21 deletions

File tree

docs/reference/commandline/image_import.md

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ Import the contents from a tarball to create a filesystem image
99

1010
### Options
1111

12-
| Name | Type | Default | Description |
13-
|:------------------|:---------|:--------|:--------------------------------------------------|
14-
| `-c`, `--change` | `list` | | Apply Dockerfile instruction to the created image |
15-
| `-m`, `--message` | `string` | | Set commit message for imported image |
16-
| `--platform` | `string` | | Set platform if server is multi-platform capable |
12+
| Name | Type | Default | Description |
13+
|:------------------------------------------|:---------|:--------|:--------------------------------------------------|
14+
| [`-c`](#change), [`--change`](#change) | `list` | | Apply Dockerfile instruction to the created image |
15+
| [`-m`](#message), [`--message`](#message) | `string` | | Set commit message for imported image |
16+
| `--platform` | `string` | | Set platform if server is multi-platform capable |
1717

1818

1919
<!---MARKER_GEN_END-->
@@ -28,10 +28,6 @@ specify an archive, Docker untars it in the container relative to the `/`
2828
the host. To import from a remote location, specify a `URI` that begins with the
2929
`http://` or `https://` protocol.
3030

31-
The `--change` option applies `Dockerfile` instructions to the image that is
32-
created. Supported `Dockerfile` instructions:
33-
`CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR`
34-
3531
## Examples
3632

3733
### Import from a remote location
@@ -50,12 +46,6 @@ Import to docker via pipe and `STDIN`.
5046
$ cat exampleimage.tgz | docker import - exampleimagelocal:new
5147
```
5248

53-
Import with a commit message.
54-
55-
```console
56-
$ cat exampleimage.tgz | docker import --message "New image imported from tarball" - exampleimagelocal:new
57-
```
58-
5949
Import to docker from a local archive.
6050

6151
```console
@@ -68,17 +58,55 @@ $ docker import /path/to/exampleimage.tgz
6858
$ sudo tar -c . | docker import - exampleimagedir
6959
```
7060

71-
### Import from a local directory with new configurations
72-
73-
```console
74-
$ sudo tar -c . | docker import --change "ENV DEBUG=true" - exampleimagedir
75-
```
76-
7761
Note the `sudo` in this example – you must preserve
7862
the ownership of the files (especially root ownership) during the
7963
archiving with tar. If you are not root (or the sudo command) when you
8064
tar, then the ownerships might not get preserved.
8165

66+
### <a name="change"></a> Import with new configurations (-c, --change)
67+
68+
The `--change` option applies `Dockerfile` instructions to the image that is
69+
created. Not all `Dockerfile` instructions are supported; the list of instructions
70+
is limited to metadata (configuration) changes. The following `Dockerfile`
71+
instructions are supported:
72+
73+
- [`CMD`](https://docs.docker.com/reference/dockerfile/#cmd)
74+
- [`ENTRYPOINT`](https://docs.docker.com/reference/dockerfile/#entrypoint)
75+
- [`ENV`](https://docs.docker.com/reference/dockerfile/#env)
76+
- [`EXPOSE`](https://docs.docker.com/reference/dockerfile/#expose)
77+
- [`ONBUILD`](https://docs.docker.com/reference/dockerfile/#onbuild)
78+
- [`USER`](https://docs.docker.com/reference/dockerfile/#user)
79+
- [`VOLUME`](https://docs.docker.com/reference/dockerfile/#volume)
80+
- [`WORKDIR`](https://docs.docker.com/reference/dockerfile/#workdir)
81+
82+
The following example imports an image from a TAR-file containing a root-filesystem,
83+
and sets the `DEBUG` environment-variable in the resulting image:
84+
85+
```console
86+
$ docker import --change "ENV DEBUG=true" ./rootfs.tgz exampleimagedir
87+
```
88+
89+
### <a name="message"></a> Import with a commit message (-m, --message)
90+
91+
The `--message` (or `-m`) option allows you to set a custom comment in
92+
the image's metadata. The following example imports an image from a local
93+
archive and sets a custom message.
94+
95+
```console
96+
$ docker import --message "New image imported from tarball" ./rootfs.tgz exampleimagelocal:new
97+
sha256:25e54c0df7dc49da9093d50541e0ed4508a6b78705057f1a9bebf1d564e2cb00
98+
```
99+
100+
After importing, the message is set in the "Comment" field of the image's
101+
configuration, which is shown when viewing the image's history:
102+
103+
```console
104+
$ docker image history exampleimagelocal:new
105+
106+
IMAGE CREATED CREATED BY SIZE COMMENT
107+
25e54c0df7dc 2 minutes ago 53.6MB New image imported from tarball
108+
```
109+
82110
### When the daemon supports multiple operating systems
83111

84112
If the daemon supports multiple operating systems, and the image being imported

0 commit comments

Comments
 (0)