Update docker.md

main
Nguyen Tran Hau 2020-06-12 17:08:46 +07:00 committed by GitHub
parent 9528a350d6
commit 36c6ec08d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 16 deletions

View File

@ -17,25 +17,25 @@ Add your user to `docker` group:
sudo usermod -aG docker $USER
```
Delete all images, containers, volumes, and networks that are not associated with a container (dangling):
## Command-line
Remove unused data:
```sh
docker system prune
docker system prune -a
```
Read [docker run](https://docs.docker.com/engine/reference/commandline/run/).
Docker run options:
| option | example | explain |
| -------- | --------------- | ----------------------------------------- |
| `-i` | | Keep STDIN open even if not attached |
| --------------------- | ------------------------ | --------------------------------------- |
| `--detach`, `-d` | | Run container in background |
| `--env`, `-e` | `-e PLATFORM=linux` | Set environment variables |
| `--interactive`, `-i` | | Keep STDIN open |
| `--name` | | |
| `-p` | `-p 8080:80` | Publish container port : host port |
| `--rm` | | |
| `-t` | | Allocate a pseudo-TTY |
| `-v` | `-v ~/abc:/abc` | Bind host directory : container directory |
Example run `ubuntu` image:
```sh
docker run --rm -it ubuntu
```
| `--publish`, `-p` | `-p 8080:80` | Publish container port:host port |
| `--rm` | | Remove container when exit |
| `--tty`, `-t` | | Allocate a pseudo-TTY |
| `--volume`, `-v` | `-v "$(pwd)"/data:/data` | Bind host directory:container directory |