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 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 ```sh
docker system prune docker system prune
docker system prune -a
``` ```
Read [docker run](https://docs.docker.com/engine/reference/commandline/run/). Docker run options:
| option | example | explain | | option | example | explain |
| -------- | --------------- | ----------------------------------------- | | --------------------- | ------------------------ | --------------------------------------- |
| `-i` | | Keep STDIN open even if not attached | | `--detach`, `-d` | | Run container in background |
| `--name` | | | | `--env`, `-e` | `-e PLATFORM=linux` | Set environment variables |
| `-p` | `-p 8080:80` | Publish container port : host port | | `--interactive`, `-i` | | Keep STDIN open |
| `--rm` | | | | `--name` | | |
| `-t` | | Allocate a pseudo-TTY | | `--publish`, `-p` | `-p 8080:80` | Publish container port:host port |
| `-v` | `-v ~/abc:/abc` | Bind host directory : container directory | | `--rm` | | Remove container when exit |
| `--tty`, `-t` | | Allocate a pseudo-TTY |
Example run `ubuntu` image: | `--volume`, `-v` | `-v "$(pwd)"/data:/data` | Bind host directory:container directory |
```sh
docker run --rm -it ubuntu
```