lk/virtualization/docker.md

73 lines
943 B
Markdown
Raw Normal View History

2022-01-18 12:36:01 +00:00
---
title: "Docker"
2022-02-04 08:24:02 +00:00
tags: [ "documentation", "Virtualization" ]
2022-01-18 12:36:01 +00:00
---
2025-02-12 14:01:15 +00:00
```sh
sudo pacman -S docker
```
2021-11-24 00:57:41 +00:00
2025-02-12 14:01:15 +00:00
```sh
sudo usermod -aG docker $USER
```
2021-11-24 00:57:41 +00:00
2025-02-12 14:01:15 +00:00
```sh
sudo systemctl start docker
```
2021-11-24 00:57:41 +00:00
You need to either log out and back in again to be in the docker group, or run everything as root.
2025-02-12 14:01:15 +00:00
```sh
# docker info
```
2021-11-24 00:57:41 +00:00
This should show you things are working.
Search for a distro you want
2025-02-12 14:01:15 +00:00
```sh
docker search debian
```
2021-11-24 00:57:41 +00:00
If you get a hit, pull it.
2025-02-12 14:01:15 +00:00
```sh
docker pull debian
```
2021-11-24 00:57:41 +00:00
Then run a live image:
2025-02-12 14:01:15 +00:00
```sh
docker run -it debian
```
2021-11-24 00:57:41 +00:00
2021-12-30 15:17:09 +00:00
# Delete
Check currently running containers with
2025-02-12 14:01:15 +00:00
```sh
docker ps
```
2021-12-30 15:17:09 +00:00
Check all containers with
2025-02-12 14:01:15 +00:00
```sh
docker ps -a
```
2021-12-30 15:17:09 +00:00
Now we can get a list of all containers.
To delete one, take the id, e.g. '97796727e883', and run:
2025-02-12 14:01:15 +00:00
```sh
docker rm 97796727e883
```
2021-12-30 15:17:09 +00:00
# Networking
Get a list of docker container ips
2025-02-12 14:01:15 +00:00
```sh
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' *container_name_or_id*
```
2021-12-30 15:17:09 +00:00