mirror of
https://github.com/wsargent/docker-cheat-sheet.git
synced 2025-09-22 05:40:50 +02:00
Update README.md
This commit is contained in:
parent
8f9634a5bb
commit
06ceeaa164
1 changed files with 16 additions and 15 deletions
15
README.md
15
README.md
|
@ -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 \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue