lk/virtualization/docker.md

73 lines
965 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
---
```bash
sudo pacman -S docker
```
2021-11-24 00:57:41 +00:00
```bash
sudo usermod -aG docker $USER
```
2021-11-24 00:57:41 +00:00
```bash
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.
```bash
# docker info
```
2021-11-24 00:57:41 +00:00
This should show you things are working.
Search for a distro you want
```bash
docker search debian
```
2021-11-24 00:57:41 +00:00
If you get a hit, pull it.
```bash
docker pull debian
```
2021-11-24 00:57:41 +00:00
Then run a live image:
```bash
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
```bash
docker ps
```
2021-12-30 15:17:09 +00:00
Check all containers with
```bash
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:
```bash
docker rm 97796727e883
```
2021-12-30 15:17:09 +00:00
# Networking
Get a list of docker container ips
```bash
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' *container_name_or_id*
```
2021-12-30 15:17:09 +00:00