Skip to content

Instantly share code, notes, and snippets.

@luckman212
Created September 1, 2023 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luckman212/ffeb4f75f8e908847a15dc98b124426a to your computer and use it in GitHub Desktop.
Save luckman212/ffeb4f75f8e908847a15dc98b124426a to your computer and use it in GitHub Desktop.
Obsidian Header Linking Bug
tags uid
docker
main
moc
58ee12f7-54c8-4db0-9418-0b1e532355bb

[!Warning] The docker-compose command is deprecated As of V2, docker-compose is now part of docker proper. Any commands should work simply by removing the dash (-).

However, as of Sep 2023, Docker on Synology still does not support the newer command format.

[!success] See here for help switching from snap to apt version Docker containers running, but not showing up in docker ps

Links

[!tip] Filename for Docker compose YAML config file The default path for a Compose file is compose.yaml (preferred) or compose.yml that is placed in the working directory. Compose also supports docker-compose.yaml and docker-compose.yml for backwards compatibility of earlier versions. If both files exist, Compose prefers the canonical compose.yaml.

Real-world Uses of Docker Compose

  • [[Run periodic speedtests and graph historic data|speedtest-tracker]]
  • [[BookStack]]
  • [[Docker on Ubuntu20 - Gatus|Gatus]]

Concepts

  • Data/changes are persistent by default, but will be lost when the container is rebuilt or updated
  • For storing data that should persist across rebuilds, use volumes
  • Images are built with Dockerfiles

Environment Variables

[!bug] Don't try to edit vars after containers are built You can only set up variables during container creation (via -e FOO=BAR) It is not really feasible or recommended to change them after.

Generating Compose Files (compose.yml)

To paste a compose file in from Terminal

cat <<'EOF' >compose.yml

(...YAML...)

EOF

Dockerfiles

Troubleshooting

Volumes

[!tip] Default location for Volumes (aka Root Dir) On default Docker installs (Linux) Named Volumes are typically stored at /var/lib/docker/volumes. On Synology however, you'll find them at /volume1/@docker/volumes. Bind mounts on the other hand can be placed anywhere.

To programmatically determine the root dir, you can execute docker info -f "{{.DockerRootDir}}/volumes"

[!example] Auto-creation of BIND mounts Recent versions of docker-compose support automatic creation of missing paths, by specifying the following directives in the compose file:

volumes:
  - type: bind
    source: /volume1/docker/foo
    target: /data
    bind:
      create_host_path: true

N.B.—this doesn't currently seem to work on Synology!

docker inspect -f '{{ json .Mounts }}' name | jq
docker inspect -f '{{ .Mounts }}' name
docker inspect <name> | jq -r '.[].Mounts[].Source'
docker inspect foo | jq -r 'map(.Mounts[] | [.Type, .Source] )[] | @tsv'

docker container ls -q | while read id; do docker inspect $id | jq -r '.[].Mounts[].Source'; done
docker container ls -q | while read id; do docker inspect $id -f '{{ .Mounts }}'; done

docker volume ls ...
docker volume ls --format "{{.Name}} {{.Mountpoint}}"

docker ps -aq
docker ps -a --format '{{ .ID }}' 

Networking

Status of Single Container

docker inspect -f '{{.State.Status}}' foo1

Logs - Tailing

journalctl -xu docker.service
docker logs -f container-name
docker events --filter name=container

Debugging a Container that won't start

docker run -it pairdrop sh
/usr/local/bin/docker-entrypoint.sh

Synology

[!question] on Synology, Docker Compose configs are called "Projects"

[!warning] Updating docker-compose binary Synology comes with an outdated version of docker-compose. You can download the latest from here and then copy it to /usr/local/bin (find your architecture with uname -m)

# /usr/local/bin/docker-compose version
Docker Compose version v2.9.0-6413-g38f6acd
# docker-compose version
Docker Compose version v2.9.0-6413-g38f6acd
# ./docker-compose-linux-x86_64 version
Docker Compose version v2.21.0

Screenshots of setting up a Project

![[IMG-20230831100452447.png|500]]

![[IMG-20230831100452601.png|500]]

![[IMG-20230831100452648.png|500]]

![[IMG-20230831100452734.png|500]]

![[IMG-20230831100452823.png|500]]

![[IMG-20230831100452894.png|500]]

![[IMG-20230831100435117.png|300]]

![[IMG-20230831100452948.png|500]]

![[IMG-20230831100453007.png|500]]

@luckman212
Copy link
Author

Video

header_linking.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment