Category: DevOps

Docker Points

  • Network mode: default bridge mode [not shared with host] , Other: host [network same as host]
  • from container to local host, URL to access the host  : docker.host.internal
  • Docker volumes :
    • Annonymous : removed on docker remove
    • Docker volume: does not remove but is used by docker internally
    • Bind mount: local host path
  • Each command in the docker file is the layer, and layers are cached  during the build
  • The container has name and Image have tags.
  • .dockerignore to ignore the current folder file for part of image
  • Env variable for container and ARG variable for image build
  • Attached mode and detacher mode, -it for the interactive terminal
  • Docker compose : depends_upon and stdin_open
  • .env_file: to skip the env from git commit
  • To accept the input from console. docker run should be executed with -it 
  • Docker exec command to run the command inside the container from host 
    • Docker exec <containername >
  • Docker compose, we can run the individual container with run command as well
    • Docker-compose run <service name>
  • Multi-stage build, where one is used for build and the artifact for that is used in another but the number of images is 1.

Git Utilities and hacks

Although GIT is an old topic, still i am adding a collection of basic and useful git utilities and hacks that is helpful in day-to-day git cli interaction.

Reference to learn git command and usage

https://gitimmersion.com/

Setting up default credential

to setup the credential, we can create a .git-credentials file user home directory

https://<usernmae>:<password>@bitbucket.org
https://<usernmae>:<password>@github.com

these will be used during remote operation

Setup alias to the git command

to setup the alias, we can create a .gitconfig file at the git project

[alias]
  co = checkout
  ci = commit
  st = status
  br = branch
  hist = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
  type = cat-file -t
  dump = cat-file -p

after setting this up, you can execute the command line

>>> git hist # instead of git log that will show a formatted output

You can also define some other config as well

[user]
	name = chandra
	email = chandra
[cola]
	spellcheck = false
[credential]
	helper = store
[core]
	filemode = false

you can define this under user home directory to be effective at all or project wise as well

Ignoring some file [Project wise]

You can create a .gitignore file at root of the project to ignore some of the files from being part of the repo

# Node artifact files
node_modules/
dist/

# Compiled Java class files
*.class

Git repo options at local [project-wise]

Config

you can edit the file that is available under your local git repo at the path

.git/config

Hooks

You can also write shell script that can be called during git command interaction and you can put them under .git/hooks

like , execute some command before commit or after commit

There are already sample available, you can rename them