# Catatan Seekor Docker

* [Compose file version 3 reference](https://docs.docker.com/compose/compose-file/compose-file-v3/)
* [Cron + Docker = The Easiest Job Scheduler You’ll Ever Create](https://levelup.gitconnected.com/cron-docker-the-easiest-job-scheduler-youll-ever-create-e1753eb5ea44)
* [Docker anti-patterns](https://codefresh.io/containers/docker-anti-patterns/)
* [Docker rmi](https://www.freecodecamp.org/news/how-to-remove-images-in-docker/)
* [How To Set Up a Private Docker Registry on Ubuntu 20.04](https://www.digitalocean.com/community/tutorials/how-to-set-up-a-private-docker-registry-on-ubuntu-20-04)
* [Multi-Stage Docker Builds for Creating Tiny Go Images](https://medium.com/@treeder/multi-stage-docker-builds-for-creating-tiny-go-images-e0e1867efe5a)
* [Path to a Perfect Go Dockerfile](https://betterprogramming.pub/path-to-a-perfect-go-dockerfile-f7fe54b5c78c)
* [Rotating Docker Logs — Keeping your overlay folder small](https://medium.com/@Quigley_Ja/rotating-docker-logs-keeping-your-overlay-folder-small-40cfa2155412)
* [Stop and remove all docker containers and images](https://blog.baudson.de/blog/stop-and-remove-all-docker-containers-and-images)
* [Tips and Tricks of the Docker Captains](https://sudo-bmitch.github.io/presentations/dc2019/tips-and-tricks-of-the-captains.html)
* [Triple-Stage Docker Builds with Go and Angular](https://medium.com/travis-on-docker/triple-stage-docker-builds-with-go-and-angular-1b7d2006cb88)
* [Where Are Docker Container Logs Stored?](https://sematext.com/blog/docker-logs-location)

## Stackoverflow

* [Docker error - Error response from daemon: Error processing tar file: write /dir : no space left on device](https://stackoverflow.com/questions/62632388/docker-error-error-response-from-daemon-error-processing-tar-file-write-dir)
* [Docker on Windows (Boot2Docker) - certificate signed by unknown authority error](https://stackoverflow.com/questions/31205438/docker-on-windows-boot2docker-certificate-signed-by-unknown-authority-error)
* [Docker: How to clear the logs properly for a Docker container?](https://stackoverflow.com/questions/42510002/docker-how-to-clear-the-logs-properly-for-a-docker-container)
* [In Docker, "Error response from daemon: could not choose an IP address to advertise since this system has multiple addresses on different interfaces"](https://stackoverflow.com/questions/43662237/in-docker-error-response-from-daemon-could-not-choose-an-ip-address-to-advert)

## Troubleshooting

```
In ~/.docker/config.json change credsStore to credStore

https://forums.docker.com/t/docker-credential-desktop-exe-executable-file-not-found-in-path-using-wsl2/100225/5
```

## Command

### Save Docker Image to file

```bash
# Save image
docker save provider/image:v1 -o image.tar

# for multiple nodes, username, and file
cat > nodes.txt <<EOF
127.0.0.1 username
EOF

cat > images.txt << EOF
provider/image1:v1
provider/image2:v2
EOF

while read image; do
  filename=$(echo "$image" | tr '/:' '_')
  fullpath="/tmp/${filename}.tar"
  echo "Saving $image to $fullpath"
  docker save "$image" -o "$fullpath"
done < images.txt

while read ip user; do
  echo "=== Processing node $ip with user $user ==="
  while read image; do
    filename=$(echo "$image" | tr '/:' '_')
    filepath="/tmp/${filename}.tar"
    echo "--- Transferring $filepath to $ip:/tmp/"
    scp "$filepath" "$user@$ip:/tmp/"
    echo "--- Loading image $filepath on $ip"
    ssh "$user@$ip" "docker load -i /tmp/${filename}.tar"
  done < images.txt
done < nodes.txt
```

### Pods

```bash
kubectl get pods -n :docker_image -o wide
```
