Skip to content

Commit 27350ce

Browse files
ajeetrainacraig-osterhoutmikesir87dvdksn
authored
Add documentation for core Docker concepts and guides (#19786)
* Added Building Images concept pages * Formatting changes and new video link added * Rebasing the docs links * Vale formatting * Added a video for image layers * Update content/guides/docker-concepts/building-images/understanding-image-layers.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/understanding-image-layers.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/understanding-image-layers.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/understanding-image-layers.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/multi-stage-builds.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/multi-stage-builds.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/multi-stage-builds.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/multi-stage-builds.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/multi-stage-builds.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/understanding-image-layers.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/understanding-image-layers.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/writing-a-dockerfile.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/writing-a-dockerfile.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/writing-a-dockerfile.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/using-the-build-cache.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/using-the-build-cache.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/using-the-build-cache.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/using-the-build-cache.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/multi-stage-builds.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/using-the-build-cache.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/using-the-build-cache.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/using-the-build-cache.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/using-the-build-cache.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/using-the-build-cache.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/using-the-build-cache.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/using-the-build-cache.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/multi-stage-builds.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/multi-stage-builds.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/multi-stage-builds.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/multi-stage-builds.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/multi-stage-builds.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/multi-stage-builds.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/multi-stage-builds.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/multi-stage-builds.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/multi-stage-builds.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/multi-stage-builds.md Co-authored-by: Craig Osterhout <[email protected]> * Made changes to resolve the PR reviewed comments * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/understanding-image-layers.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/writing-a-dockerfile.md Co-authored-by: Craig Osterhout <[email protected]> * Update content/guides/docker-concepts/building-images/understanding-image-layers.md Co-authored-by: Craig Osterhout <[email protected]> * removed unnecessary files * fixed a command based on the PR review * Update content/guides/docker-concepts/building-images/understanding-image-layers.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/using-the-build-cache.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/using-the-build-cache.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/multi-stage-builds.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/multi-stage-builds.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/multi-stage-builds.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/multi-stage-builds.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/understanding-image-layers.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/build-tag-and-publish-an-image.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/multi-stage-builds.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/multi-stage-builds.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/understanding-image-layers.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/understanding-image-layers.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/understanding-image-layers.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/understanding-image-layers.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/understanding-image-layers.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/using-the-build-cache.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/using-the-build-cache.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/using-the-build-cache.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/writing-a-dockerfile.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/using-the-build-cache.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/using-the-build-cache.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/using-the-build-cache.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/using-the-build-cache.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/using-the-build-cache.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/using-the-build-cache.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/using-the-build-cache.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/writing-a-dockerfile.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/writing-a-dockerfile.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/writing-a-dockerfile.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/writing-a-dockerfile.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/writing-a-dockerfile.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/understanding-image-layers.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/understanding-image-layers.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/understanding-image-layers.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/understanding-image-layers.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/understanding-image-layers.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/using-the-build-cache.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/multi-stage-builds.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/multi-stage-builds.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/understanding-image-layers.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/multi-stage-builds.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/understanding-image-layers.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/understanding-image-layers.md Co-authored-by: David Karlsson <[email protected]> * Update content/guides/docker-concepts/building-images/using-the-build-cache.md Co-authored-by: David Karlsson <[email protected]> * Delete content/guides/docker-concepts/building-images/images/container_image_layer_reuse.svg * Added a note for Eclpise temurin --------- Co-authored-by: Craig Osterhout <[email protected]> Co-authored-by: Michael Irwin <[email protected]> Co-authored-by: David Karlsson <[email protected]>
1 parent 872729c commit 27350ce

File tree

10 files changed

+1248
-2
lines changed

10 files changed

+1248
-2
lines changed
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
---
2+
title: Build, tag, and publish an image
3+
keywords: concepts, build, images, container, docker desktop
4+
description: This concept page will teach you how to build, tag, and publish an image to Docker Hub or any other registry
5+
---
6+
7+
{{< youtube-embed chiiGLlYRlY >}}
8+
9+
## Explanation
10+
11+
In this guide, you will learn the following:
12+
13+
- Building images - the process of building an image based on a `Dockerfile`
14+
- Tagging images - the process of giving an image a name, which also determines where the image can be distributed
15+
- Publishing images - the process to distribute or share the newly created image using a container registry
16+
17+
### Building images
18+
19+
Most often, images are built using a Dockerfile. The most basic `docker build` command might look like the following:
20+
21+
```bash
22+
docker build .
23+
```
24+
25+
The final `.` in the command provides the path or URL to the [build context](https://docs.docker.com/build/building/context/#what-is-a-build-context). At this location, the builder will find the `Dockerfile` and other referenced files.
26+
27+
When you run a build, the builder pulls the base image, if needed, and then runs the instructions specified in the Dockerfile.
28+
29+
With the previous command, the image will have no name, but the output will provide the ID of the image. As an example, the previous command might produce the following output:
30+
31+
```console
32+
$ docker build .
33+
[+] Building 3.5s (11/11) FINISHED docker:desktop-linux
34+
=> [internal] load build definition from Dockerfile 0.0s
35+
=> => transferring dockerfile: 308B 0.0s
36+
=> [internal] load metadata for docker.io/library/python:3.12 0.0s
37+
=> [internal] load .dockerignore 0.0s
38+
=> => transferring context: 2B 0.0s
39+
=> [1/6] FROM docker.io/library/python:3.12 0.0s
40+
=> [internal] load build context 0.0s
41+
=> => transferring context: 123B 0.0s
42+
=> [2/6] WORKDIR /usr/local/app 0.0s
43+
=> [3/6] RUN useradd app 0.1s
44+
=> [4/6] COPY ./requirements.txt ./requirements.txt 0.0s
45+
=> [5/6] RUN pip install --no-cache-dir --upgrade -r requirements.txt 3.2s
46+
=> [6/6] COPY ./app ./app 0.0s
47+
=> exporting to image 0.1s
48+
=> => exporting layers 0.1s
49+
=> => writing image sha256:9924dfd9350407b3df01d1a0e1033b1e543523ce7d5d5e2c83a724480ebe8f00 0.0s
50+
```
51+
52+
With the previous output, you could start a container by using the referenced image:
53+
54+
```console
55+
docker run sha256:9924dfd9350407b3df01d1a0e1033b1e543523ce7d5d5e2c83a724480ebe8f00
56+
```
57+
58+
That name certainly isn't memorable, which is where tagging becomes useful.
59+
60+
61+
### Tagging images
62+
63+
Tagging images is the method to provide an image with a memorable name. However, there is a structure to the name of an image. A full image name has the following structure:
64+
65+
```text
66+
[HOST[:PORT_NUMBER]/]PATH[:TAG]
67+
```
68+
69+
- `HOST`: The optional registry hostname where the image is located. If no host is specified, Docker's public registry at `docker.io` is used by default.
70+
- `PORT_NUMBER`: The registry port number if a hostname is provided
71+
- `PATH`: The path of the image, consisting of slash-separated components. For Docker Hub, the format follows `[NAMESPACE/]REPOSITORY`, where namespace is either a user's or organization's name. If no namespace is specified, `library` is used, which is the namespace for Docker Official Images.
72+
- `TAG`: A custom, human-readable identifier that's typically used to identify different versions or variants of an image. If no tag is specified, `latest` is used by default.
73+
74+
Some examples of image names include:
75+
76+
- `nginx`, equivalent to `docker.io/library/alpine:latest`: this pulls an image from the `docker.io` registry, the `library` namespace, the `nginx` image repository, and the `latest` tag.
77+
- `docker/welcome-to-docker`, equivalent to `docker.io/docker/welcome-to-docker:latest`: this pulls an image from the `docker.io` registry, the `docker` namespace, the `welcome-to-docker` image repository, and the `latest` tag
78+
- `ghcr.io/dockersamples/example-voting-app-vote:pr-311`: this pulls an image from the GitHub Container Registry, the `dockersamples` namespace, the `example-voting-app-vote` image repository, and the `pr-311` tag
79+
80+
To tag an image during a build, add the `-t` or `--tag` flag:
81+
82+
```console
83+
docker build -t my-username/my-image .
84+
```
85+
86+
If you've already built an image, you can add another tag to the image by using the [`docker image tag`](https://docs.docker.com/engine/reference/commandline/image_tag/) command:
87+
88+
```console
89+
docker image tag my-username/my-image another-username/another-image:v1
90+
```
91+
92+
### Publishing images
93+
94+
Once you have an image built and tagged, you're ready to push it to a registry. To do so, use the [`docker push`](https://docs.docker.com/engine/reference/commandline/image_push/) command:
95+
96+
```console
97+
docker push my-username/my-image
98+
```
99+
100+
Within a few seconds, all of the layers for your image will be pushed to the registry.
101+
102+
> **Requiring authentication**
103+
>
104+
> Before you're able to push an image to a repository, you will need to be authenticated.
105+
> To do so, simply use the [docker login](https://docs.docker.com/engine/reference/commandline/login/) command.
106+
{ .information }
107+
108+
## Try it out
109+
110+
In this hands-on guide, you will build a simple image using a provided Dockerfile and push it to Docker Hub.
111+
112+
### Set up
113+
114+
1. Get the sample application.
115+
116+
If you have Git, you can clone the repository for the sample application. Otherwise, you can download the sample application. Choose one of the following options.
117+
118+
{{< tabs >}}
119+
{{< tab name="Clone with git" >}}
120+
121+
Use the following command in a terminal to clone the sample application repository.
122+
123+
```console
124+
$ git clone https://github.com/docker/getting-started-todo-app
125+
```
126+
{{< /tab >}}
127+
{{< tab name="Download" >}}
128+
129+
Download the source and extract it.
130+
131+
{{< button url="https://github.com/docker/getting-started-todo-app/raw/cd61f824da7a614a8298db503eed6630eeee33a3/app.zip" text="Download the source" >}}
132+
133+
{{< /tab >}}
134+
{{< /tabs >}}
135+
136+
137+
2. [Download and install](https://www.docker.com/products/docker-desktop/) Docker Desktop.
138+
139+
3. If you don't have a Docker account yet, [create one now](https://hub.docker.com/). Once you've done that, sign in to Docker Desktop using that account.
140+
141+
142+
### Build an image
143+
144+
Now that you have a repository on Docker Hub, it's time for you to build an image and push it to the repository.
145+
146+
1. Using a terminal in the root of the sample app repository, run the following command. Replace `YOUR_DOCKER_USERNAME` with your Docker Hub username:
147+
148+
```console
149+
$ docker build -t <YOUR_DOCKER_USERNAME>/concepts-build-image-demo .
150+
```
151+
152+
As an example, if your username is `mobywhale`, you would run the command:
153+
154+
```console
155+
$ docker build -t mobywhale/concepts-build-image-demo .
156+
```
157+
158+
2. Once the build has completed, you can view the image by using the following command:
159+
160+
```console
161+
$ docker image ls
162+
```
163+
164+
The command will produce output similar to the following:
165+
166+
```plaintext
167+
REPOSITORY TAG IMAGE ID CREATED SIZE
168+
mobywhale/concepts-build-image-demo latest 746c7e06537f 24 seconds ago 354MB
169+
```
170+
171+
3. You can actually view the history (or how the image was created) by using the [docker image history](/reference/cli/docker/image/history/) command:
172+
173+
```console
174+
$ docker image history mobywhale/concepts-build-image-demo
175+
```
176+
177+
You'll then see output similar to the following:
178+
179+
```plaintext
180+
IMAGE CREATED CREATED BY SIZE COMMENT
181+
f279389d5f01 8 seconds ago CMD ["node" "./src/index.js"] 0B buildkit.dockerfile.v0
182+
<missing> 8 seconds ago EXPOSE map[3000/tcp:{}] 0B buildkit.dockerfile.v0
183+
<missing> 8 seconds ago WORKDIR /app 8.19kB buildkit.dockerfile.v0
184+
<missing> 4 days ago /bin/sh -c #(nop) CMD ["node"] 0B
185+
<missing> 4 days ago /bin/sh -c #(nop) ENTRYPOINT ["docker-entry… 0B
186+
<missing> 4 days ago /bin/sh -c #(nop) COPY file:4d192565a7220e13… 20.5kB
187+
<missing> 4 days ago /bin/sh -c apk add --no-cache --virtual .bui… 7.92MB
188+
<missing> 4 days ago /bin/sh -c #(nop) ENV YARN_VERSION=1.22.19 0B
189+
<missing> 4 days ago /bin/sh -c addgroup -g 1000 node && addu… 126MB
190+
<missing> 4 days ago /bin/sh -c #(nop) ENV NODE_VERSION=20.12.0 0B
191+
<missing> 2 months ago /bin/sh -c #(nop) CMD ["/bin/sh"] 0B
192+
<missing> 2 months ago /bin/sh -c #(nop) ADD file:d0764a717d1e9d0af… 8.42MB
193+
```
194+
195+
This output shows the layers of the image, highlighting the layers you added and those that were inherited from your base image.
196+
197+
### Push the image
198+
199+
Now that you have an image built, it's time to push the image to a registry.
200+
201+
1. Push the image using the [docker push](/reference/cli/docker/image/push/) command:
202+
203+
```console
204+
$ docker push <YOUR_DOCKER_USERNAME>/concepts-build-image-demo
205+
```
206+
207+
If you receive a `requested access to the resource is denied`, make sure you are both logged in and that your Docker username is correct in the image tag.
208+
209+
After a moment, your image should be pushed to Docker Hub.
210+
211+
## Additional resources
212+
213+
To learn more about building, tagging, and publishing images, visit the following resources:
214+
215+
* [What is a build context?](/build/building/context/#what-is-a-build-context)
216+
* [docker build reference](/engine/reference/commandline/image_build/)
217+
* [docker image tag reference](/engine/reference/commandline/image_tag/)
218+
* [docker push reference](/engine/reference/commandline/image_push/)
219+
* [What is a registry?](/guides/docker-concepts/the-basics/what-is-a-registry/)
220+
221+
## Next steps
222+
223+
Now that you have learned about building and publishing images, it's time to learn how to speed up the build process using the Docker build cache.
224+
225+
{{< button text="Using the build cache" url="using-the-build-cache" >}}
226+
227+
17.8 KB
Loading
10.7 KB
Loading
14.6 KB
Loading
37.6 KB
Loading

0 commit comments

Comments
 (0)