Docker

Various notes on using Docker. Mostly OS-agnostic, but may include OS-specific tips and tricks.

Running

Configuration tips

- 



## Maintenance Activities


### Testing / troubleshooting Docker install

- Test if Docker has Internet connectivity
  `docker run --rm busybox ping -c 6 8.8.8.8`
	- The default network for containers is the bridge network, and Internet access from the bridge network has been **deprecated**.
	- If the above doesn’t work, try `docker run --rm --network host busybox ping -c 6 8.8.8.8`
- Test if DNS resolution is working
  `docker run --rm busybox ping -c 6 duckduckgo.com`
  if DNS is not working, try adding DNS servers in `/etc/docker/daemon.json`
- 

### Updating Docker Images

#### Watchtower
To easily manage docker image updates in a #homelab setting, look into using [Watchtower](https://github.com/containrrr/watchtower?tab=readme-ov-file) by "*containerrr*"
- [Watchtower docs](https://containrrr.dev/watchtower/)
- 

**Basic startup command**

docker run -d
--name watchtower
-v /var/run/docker.sock:/var/run/docker.sock
containrrr/watchtower


By default, Watchtower will update all running containers on the system.  To have it monitor specific images, specify their name on the command line as an argument, no flag needed.

### Removing Containers and images
Since a container is the executed version of an image, this creates dependencies.  In order to remove an image, you need to stop, remove the container first.  Assuming the running container has an id of  *abcd* and an image called *image/wxyz*, it would be:
1. `docker ps -a` to find the container’s id of *abcd*
2. `docker stop abcd` to stop the container
3. `docker rm abcd` (alternatively `docker container rm abcd`) to remove the stopped container
4. `docker rmi image/wxyz`  (alternatively `docker image rm`) to remove the image


### Cleaning up
- Some Docker cleanup commands I’ve collected
-