Despite being wrong we are kinda calling our users dumb, I feel it is a bit
demeaning. As well as just wrong.
Docker-DCO-1.1-Signed-off-by: Jessie Frazelle <princess@docker.com> (github: jfrazelle)
Docker-DCO-1.1-Signed-off-by: Jessie Frazelle <hugs@docker.com> (github: jfrazelle)
| ... | ... |
@@ -291,28 +291,22 @@ auto-extraction capability, you should always use `COPY`. |
| 291 | 291 |
|
| 292 | 292 |
### [`ENTRYPOINT`](https://docs.docker.com/reference/builder/#entrypoint) |
| 293 | 293 |
|
| 294 |
-The best use for `ENTRYPOINT` is as a helper script. Using `ENTRYPOINT` for |
|
| 295 |
-other tasks can make your code harder to understand. For example, |
|
| 294 |
+The best use for `ENTRYPOINT` is as the main command. |
|
| 296 | 295 |
|
| 297 |
-....docker run -it official-image bash |
|
| 296 |
+Let's start with an example, of an image for the cli tool `s3cmd`: |
|
| 298 | 297 |
|
| 299 |
-is much easier to understand than |
|
| 298 |
+ ENTRYPOINT ["s3cmd"] |
|
| 299 |
+ CMD ["--help"] |
|
| 300 | 300 |
|
| 301 |
-....docker run -it --entrypoint bash official-image -i |
|
| 301 |
+Now people who consume this image can easily run commands via syntax like the |
|
| 302 |
+following: |
|
| 302 | 303 |
|
| 303 |
-This is especially true for new Docker users, who might naturally assume the |
|
| 304 |
-above command will work fine. In cases where an image uses `ENTRYPOINT` for |
|
| 305 |
-anything other than just a wrapper script, the command will fail and the |
|
| 306 |
-beginning user will then be forced to learn about `ENTRYPOINT` and |
|
| 307 |
-`--entrypoint`. |
|
| 304 |
+ $ docker run scmd ls s3://mybucket |
|
| 308 | 305 |
|
| 309 |
-In order to avoid a situation where commands are run without clear visibility |
|
| 310 |
-to the user, make sure your script ends with something like `exec "$@"` (see |
|
| 311 |
-[the exec builtin command](http://wiki.bash-hackers.org/commands/builtin/exec)). |
|
| 312 |
-After the entrypoint completes, the script will transparently bootstrap the command |
|
| 313 |
-invoked by the user, making what has been run clear to the user (for example, |
|
| 314 |
-`docker run -it mysql mysqld --some --flags` will transparently run |
|
| 315 |
-`mysqld --some --flags` after `ENTRYPOINT` runs `initdb`). |
|
| 306 |
+This is nice because the image name can double as a refernce to the binary as |
|
| 307 |
+shown in the command above. |
|
| 308 |
+ |
|
| 309 |
+People also often use `ENTRYPOINT` is as a helper script. |
|
| 316 | 310 |
|
| 317 | 311 |
For example, let’s look at the `Dockerfile` for the |
| 318 | 312 |
[Postgres Official Image](https://github.com/docker-library/postgres). |