2020-03-21 09:24:35 +00:00
|
|
|
# Docker
|
|
|
|
|
2020-05-09 18:30:08 +00:00
|
|
|
| Distribution | Package |
|
|
|
|
| ------------ | ----------------------------------------------------- |
|
2020-11-04 07:53:44 +00:00
|
|
|
| Arch Linux | `docker docker-compose` |
|
2021-02-26 08:28:28 +00:00
|
|
|
| Debian | [See](https://docs.docker.com/engine/install/debian/) |
|
2020-05-09 18:30:08 +00:00
|
|
|
| Ubuntu | [See](https://docs.docker.com/engine/install/ubuntu/) |
|
2021-02-26 08:28:28 +00:00
|
|
|
| Fedor | [See](https://docs.docker.com/engine/install/fedora/) |
|
2020-03-21 09:24:35 +00:00
|
|
|
|
2021-04-03 16:51:01 +00:00
|
|
|
Service: `docker.service`
|
2020-03-31 07:46:58 +00:00
|
|
|
|
|
|
|
Add your user to `docker` group:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
sudo usermod -aG docker $USER
|
|
|
|
```
|
2020-03-21 09:24:35 +00:00
|
|
|
|
2020-07-23 08:14:13 +00:00
|
|
|
## Commands
|
2020-06-12 10:08:46 +00:00
|
|
|
|
|
|
|
Remove unused data:
|
2020-03-21 09:24:35 +00:00
|
|
|
|
|
|
|
```sh
|
2020-07-20 08:45:32 +00:00
|
|
|
docker system prune --volumes
|
2020-03-31 09:26:22 +00:00
|
|
|
|
2020-07-20 08:45:32 +00:00
|
|
|
docker system prune --volumes -a
|
2020-03-31 09:26:22 +00:00
|
|
|
```
|
2020-06-12 10:08:46 +00:00
|
|
|
|
2020-07-23 08:14:13 +00:00
|
|
|
Inside container:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
docker exec -it container_name /bin/bash
|
|
|
|
```
|
|
|
|
|
2020-06-12 10:08:46 +00:00
|
|
|
Docker run options:
|
|
|
|
|
|
|
|
| option | example | explain |
|
|
|
|
| --------------------- | ------------------------ | --------------------------------------- |
|
|
|
|
| `--detach`, `-d` | | Run container in background |
|
|
|
|
| `--env`, `-e` | `-e PLATFORM=linux` | Set environment variables |
|
|
|
|
| `--interactive`, `-i` | | Keep STDIN open |
|
|
|
|
| `--name` | | |
|
|
|
|
| `--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 |
|
2020-07-13 07:27:08 +00:00
|
|
|
|
|
|
|
## Docker Compose
|
|
|
|
|
|
|
|
Update images:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
docker-compose pull
|
|
|
|
```
|
|
|
|
|
|
|
|
Start:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
docker-compose up
|
|
|
|
|
|
|
|
# Detach
|
|
|
|
docker-compose up -d
|
|
|
|
```
|
|
|
|
|
|
|
|
Stops:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
docker-compose down
|
|
|
|
```
|