Skip to content

Commit

Permalink
ISSUE-90 add 4 rules for CMD and ENTRYPOINT
Browse files Browse the repository at this point in the history
  • Loading branch information
ivorscott committed Nov 29, 2021
1 parent 1bf1d42 commit 75b28fa
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions dockerfiles/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ Options:
-c filename : set configuration file (default: /etc/nginx/nginx.conf)
-g directives : set global directives out of configuration file
```
### 4 Rules
There's 4 rules that describe how CMD and `ENTRYPOINT` interact.

![](/docs/images/entrypoint-cmd-4rules.png)

Here's another way to visualize what command is executed for different ENTRYPOINT / CMD combinations.

![](/docs/images/entrypoint-cmd-interaction.png)

#### Summary

Expand All @@ -75,22 +83,21 @@ You might be wondering if Docker provides a way to modify the `ENTRYPOINT` with

The `docker run` command has an optional `--entrpoint` flag for this.

![](/docs/images/--entrypoint.png)
![](/docs/images/entrypoint-flag.png)

Let's see an example that modifies both default entrypoint and command. In the previous lecture we saw how we could print nginx help text by creating a custom image. You can do the same thing in the command line.

Run:

```
docker run --rm --entrypoint nginx nginx:1.21.4 -h
````
```

In summary, you're not forced to create a new image to make changes to the entrypoint. Using the `--entrypoint` flag gives you an alternative approach while using `docker run` and any comamands and aruguments can be appended to the end like usual.

Resources
- https://docs.docker.com/engine/reference/commandline/run/#options

### Lecture 3: Using ENTRYPOINT and CMD in Docker Compose

We've seen how we can use entrypoint and command together in our Dockerfiles and with the `docker run` command, but how does it work with `docker-compose`?
Expand Down
Binary file added docs/images/entrypoint-cmd-4rules.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/entrypoint-cmd-interaction.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes

0 comments on commit 75b28fa

Please sign in to comment.