Skip to content

Instantly share code, notes, and snippets.

@davide-romanini
Last active December 11, 2021 09:37
Show Gist options
  • Save davide-romanini/ca8c5fbf0cdf7731c1b7c47d05cfe0c7 to your computer and use it in GitHub Desktop.
Save davide-romanini/ca8c5fbf0cdf7731c1b7c47d05cfe0c7 to your computer and use it in GitHub Desktop.
Personal notes

Docker on windows

  • default user is manager\containeradministrator
  • mounted volumes require a Modify permission given to Authenticated Users, otherwise move operations (user by nuget restore for example) fail. TODO: why normal write operation work even without that??

Nuget

  • mixing <PackageReference> with packages.config doesn't work: they seem to be mutually exclusive.

Cognito concepts

Git - Set +x on windows

Git flow and release management

  • develop is the main branch
  • use feature branches and pull requests
  • don't be afraid to commit on develop sometimes
  • master points to latest released version
  • releases are made with git tag -a vX.Y.Z -m '' && git push --tags
  • use semver
  • use git-semver
  • use tools like setuptools_scm, gitchangelog to avoid the need of release branches
  • release automatically on tags
  • CI builds only develop, feature branches and tags

Bash snippets

Rename files:
 -> use rename tool

for f in *.cbz; do mv "$f" "$(echo "$f"|sed -r 's/Donald Duck - (.*) - (.*).cbz/Donald Duck - \1-\2.cbz/')"; done


Find false cbr:

file *.cbr|grep Zip|cut -d: -f1

Rename to cbz:

 file *.cbr|grep Zip|cut -d: -f1|xargs -n 6 -I {} rename 's/(.*).cbr/$1.cbz/' "{}"

Extract images from pdf:
 pdfimages

Docker course

  • CopyOnWrite images are not for performance or big files. Always use volumes, avoid using the "writeable" default top layer.
  • don't assume embedding all dependencies in application layer image is always the best: consider mapping volumes.
  • never use "export running container" as image feature: no env variables, squash layers, lost reproducibility.
  • docker history: show single layers forming final images (with size)
  • ENV on bottom, to maximize build cache usage
  • multistage builds
  • volumes
    • managed: docker manages it inside its workspace
    • bind: mount existing directory
    • image level (VOLUME): automatically creates a managed volume on the mount point -> never cleaned up! Attention!
  • storageos.com to replicate volumes between hosts
  • mount from other containers, isolated by seccomp
  • docker inspect, GraphDriver: actual data on layers mount point
  • portainer.io
  • docker will die: https://cri-o.io/ (swarm already has, docker-compose?)

Network

  • bridge as default (docker0)
    • no service discovery not working on docker0 (no dns, reuse host resolv.conf)
    • veth* nic for each container
  • host: share host namespace, to be used only for special protocols (streaming) using a high port range (10000-20000)
  • networking (k8s like) container: (talk only on localhost)
  • additional docker network created networks (bridge different from docker0) spin up a dns on 172.0.0.11, where attached containers are registered by name
  • docker network connect: connect to network at runtime
  • EXPOSE is only used to automatically create iptable on random ports with -P flag, useless in k8s

SWARM

  • on single host, prefer swarm
  • raft algorithm
  • new networks: ingress (overlay) for internal nodes communications, docker_gwbridge for external communication

Kubernetes day 3

  • kubernetes.io -> docs human readable
  • https://skaffold.dev/
  • three (plus one) things to version
    • application code
    • deployment descriptors
    • configuration + secrets (different lifecycle)
  • always set resource request+limits

AWS SSO

  • Enable globally: will create administration roles in each account of organization
  • Create users/groups and assign accounts/permission sets
  • Setup AWS_DEFAULT_SSO_START_URL and AWS_DEFAULT_SSO_REGION for use with aws-sso-util
  • Use https://github.com/benkehoe/aws-sso-util to populate all profiles automatically
 $ aws-sso-util login
 $ aws-sso-util configure populate --region us-east-1 --separator - --trim-role-name Access
  • Use the various accounts with --profile or similar AWS SDK supported mechanism
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment