Update README.md

This commit is contained in:
Michael Currin 2021-09-11 15:31:13 +02:00 committed by GitHub
parent 8f9634a5bb
commit 06ceeaa164
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -497,16 +497,20 @@ Exposing incoming ports through the host container is [fiddly but doable](https:
This is done by mapping the container port to the host port (only using localhost interface) using `-p`:
```sh
docker run -p 127.0.0.1:$HOSTPORT:$CONTAINERPORT --name CONTAINER -t someimage
docker run -p 127.0.0.1:$HOSTPORT:$CONTAINERPORT \
--name CONTAINER \
-t someimage
```
You can tell Docker that the container listens on the specified network ports at runtime by using [EXPOSE](https://docs.docker.com/engine/reference/builder/#expose):
```
```Dockerfile
EXPOSE <CONTAINERPORT>
```
Note that EXPOSE does not expose the port itself -- only `-p` will do that. To expose the container's port on your localhost's port:
Note that `EXPOSE` does not expose the port itself - only `-p` will do that.
To expose the container's port on your localhost's port, run:
```sh
iptables -t nat -A DOCKER -p tcp --dport <LOCALHOSTPORT> -j DNAT --to-destination <CONTAINERIP>:<PORT>
@ -798,10 +802,7 @@ docker images -viz | dot -Tpng -o docker.png
### Slimming down Docker containers
- Cleaning APT in a RUN layer
This should be done in the same layer as other apt commands.
Otherwise, the previous layers still persist the original information and your images will still be fat.
- Cleaning APT in a `RUN` layer - This should be done in the same layer as other `apt` commands. Otherwise, the previous layers still persist the original information and your images will still be fat.
```Dockerfile
RUN {apt commands} \
&& apt-get clean \