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