til/Development/docker.md

43 lines
1.3 KiB
Markdown
Raw Normal View History

2020-03-21 09:24:35 +00:00
# Docker
2020-05-09 18:30:08 +00:00
| Distribution | Package |
| ------------ | ----------------------------------------------------- |
| Archlinux | `docker` |
| Ubuntu | [See](https://docs.docker.com/engine/install/ubuntu/) |
2020-03-21 09:24:35 +00:00
2020-05-09 18:30:08 +00:00
On Archlinux, enable and start service:
2020-03-21 09:24:35 +00:00
2020-03-31 07:46:58 +00:00
```sh
2020-05-09 16:16:00 +00:00
systemctl enable --now 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
Delete all images, containers, volumes, and networks that are not associated with a container (dangling):
```sh
docker system prune
```
2020-03-31 09:26:22 +00:00
Read [docker run](https://docs.docker.com/engine/reference/commandline/run/).
| option | example | explain |
| -------- | --------------- | ----------------------------------------- |
| `-i` | | Keep STDIN open even if not attached |
| `--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 |
2020-05-09 16:16:00 +00:00
Example run `ubuntu` image:
2020-03-31 09:26:22 +00:00
```sh
docker run --rm -it ubuntu
```