mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-09 13:44:24 +00:00
82 lines
1.9 KiB
Markdown
82 lines
1.9 KiB
Markdown
# Docker
|
|
|
|
## TL;DR
|
|
|
|
```shell
|
|
# Create containers.
|
|
docker create -h alpine-test --name alpine-test alpine
|
|
|
|
# Start containers.
|
|
docker start alpine-test
|
|
|
|
# Create and start containers.
|
|
docker run hello-world
|
|
docker run -ti --rm alpine cat /etc/apk/repositories
|
|
docker run -d --name boinc --network=host --pid=host -v "boinc:/var/lib/boinc" \
|
|
-e BOINC_GUI_RPC_PASSWORD="123" -e BOINC_CMD_LINE_OPTIONS="--allow_remote_gui_rpc" \
|
|
boinc/client
|
|
|
|
# Gracefully stop containers.
|
|
docker stop alpine-test
|
|
|
|
# Kill containers.
|
|
docker kill alpine-test
|
|
|
|
# Restart containers.
|
|
docker restart alpine-test
|
|
|
|
# Show containers' status.
|
|
docker ps
|
|
docker ps --all
|
|
|
|
# Show containers' output.
|
|
docker log alpine-test
|
|
|
|
# List processes running inside containers.
|
|
docker top alpine-test
|
|
|
|
# Show information on containers.
|
|
docker inspect alpine-test
|
|
|
|
# Cleanup.
|
|
docker rm -f alpine-test
|
|
docker rmi alpine
|
|
docker system prune -a
|
|
```
|
|
|
|
## Daemon configuration
|
|
|
|
The docker daemon is configured using the `/etc/docker/daemon.json` file:
|
|
|
|
```json
|
|
{
|
|
"default-runtime": "runc",
|
|
"dns": ['8.8.8.8', '1.1.1.1']
|
|
}
|
|
```
|
|
|
|
## Containers configuration
|
|
|
|
Docker mounts specific system files in all containers to forward its settings:
|
|
|
|
```shell
|
|
6a95fabde222$ mount
|
|
…
|
|
/dev/disk/by-uuid/1bb…eb5 on /etc/resolv.conf type btrfs (rw,…)
|
|
/dev/disk/by-uuid/1bb…eb5 on /etc/hostname type btrfs (rw,…)
|
|
/dev/disk/by-uuid/1bb…eb5 on /etc/hosts type btrfs (rw,…)
|
|
…
|
|
```
|
|
|
|
Those files come from the volume the docker container is using for its root, and are modified on the container's startup with the information from the CLI, the daemon itself and, when missing, the host.
|
|
|
|
## Sources
|
|
|
|
- [Archlinux Wiki]
|
|
- [Configuring DNS]
|
|
- [Cheatsheet]
|
|
|
|
[archlinux wiki]: https://wiki.archlinux.org/index.php/Docker
|
|
[cheatsheet]: https://collabnix.com/docker-cheatsheet/
|
|
[configuring dns]: https://dockerlabs.collabnix.com/intermediate/networking/Configuring_DNS.html
|