|
8 | 8 |
|
9 | 9 | == Dockerfile
|
10 | 10 |
|
11 |
| -Docker build images by reading instructions from a _Dockerfile_. A _Dockerfile_ is a text document that contains all the commands a user could call on the command line to assemble an image. `docker build` command uses this file and executes all the commands in succession to create an image. |
| 11 | +Docker build images by reading instructions from a _Dockerfile_. A _Dockerfile_ is a text document that contains all the commands a user could call on the command line to assemble an image. `docker image build` command uses this file and executes all the commands in succession to create an image. |
12 | 12 |
|
13 | 13 | `build` command is also passed a context that is used during image creation. This context can be a path on your local filesystem or a URL to a Git repository.
|
14 | 14 |
|
@@ -96,7 +96,7 @@ If you do not see the expected output, check your Dockerfile that the content ex
|
96 | 96 |
|
97 | 97 | Change the base image from `ubuntu` to `busybox` in `Dockerfile`. Build the image again:
|
98 | 98 |
|
99 |
| - docker build -t helloworld:2 . |
| 99 | + docker image build -t helloworld:2 . |
100 | 100 |
|
101 | 101 | and view the images using `docker image ls` command:
|
102 | 102 |
|
@@ -172,10 +172,7 @@ Let's package this application as a Docker image.
|
172 | 172 |
|
173 | 173 | Run the OpenJDK container in an interactive manner:
|
174 | 174 |
|
175 |
| -[source, text] |
176 |
| ----- |
177 |
| -docker run -it openjdk |
178 |
| ----- |
| 175 | + docker container run -it openjdk |
179 | 176 |
|
180 | 177 | This will open a terminal in the container. Check the version of Java:
|
181 | 178 |
|
@@ -206,11 +203,11 @@ CMD java -cp /usr/src/helloworld-1.0-SNAPSHOT.jar org.examples.java.App
|
206 | 203 |
|
207 | 204 | Build the image:
|
208 | 205 |
|
209 |
| - docker build -t hello-java:latest . |
| 206 | + docker image build -t hello-java:latest . |
210 | 207 |
|
211 | 208 | Run the image:
|
212 | 209 |
|
213 |
| - docker run hello-java:latest |
| 210 | + docker container run hello-java:latest |
214 | 211 |
|
215 | 212 | This displays the output:
|
216 | 213 |
|
@@ -274,7 +271,7 @@ This will show an output like:
|
274 | 271 | [INFO] DOCKER> [hellojava:latest]: Waited on log out 'Hello World!' 510 ms
|
275 | 272 | ----
|
276 | 273 |
|
277 |
| -This is similar output when running the Java application using `java` CLI or the Docker container using `docker run` command. |
| 274 | +This is similar output when running the Java application using `java` CLI or the Docker container using `docker container run` command. |
278 | 275 |
|
279 | 276 | The container is running in the foreground. Use `Ctrl` + `C` to interrupt the container and return back to terminal.
|
280 | 277 |
|
@@ -342,17 +339,17 @@ Only one change was required in the project to enable Docker packaging and runni
|
342 | 339 |
|
343 | 340 | Default entry point for a container is `/bin/sh`, the default shell.
|
344 | 341 |
|
345 |
| -Running a container as `docker run -it ubuntu` uses that command and starts the default shell. The output is shown as: |
| 342 | +Running a container as `docker container run -it ubuntu` uses that command and starts the default shell. The output is shown as: |
346 | 343 |
|
347 | 344 | ```console
|
348 |
| -> docker run -it ubuntu |
| 345 | +> docker container run -it ubuntu |
349 | 346 | root@88976ddee107:/#
|
350 | 347 | ```
|
351 | 348 |
|
352 | 349 | `ENTRYPOINT` allows to override the entry point to some other command, and even customize it. For example, a container can be started as:
|
353 | 350 |
|
354 | 351 | ```console
|
355 |
| -> docker run -it --entrypoint=/bin/cat ubuntu /etc/passwd |
| 352 | +> docker container run -it --entrypoint=/bin/cat ubuntu /etc/passwd |
356 | 353 | root:x:0:0:root:/root:/bin/bash
|
357 | 354 | daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
|
358 | 355 | bin:x:2:2:bin:/bin:/usr/sbin/nologin
|
|
0 commit comments