Joshua's Cheatsheets - General Devops And Devtools
Light
help

Laragon and Cmder

Note: Cmder is really a wrapper around ConEmu

Cmder - messed up path

If there is a mismatch between what is accessible in cmder (the terminal that launches from Laragon) and the global git/bin/bash.exe or cmd terminals, it probably has to do with system path variables.

  • Laragon/Cmder has some scripting set up to grab the global %PATH% variable equal to itself + everything in laragon/bin

    • You might to manually add some of these to the system path if you want to use them (for example, NodeJS)
  • There is also a bizarre issue with VSCode and PATH expansion; it is broken for a lot of Windows users unless ran as an administrator

    • This is the case for me; see broken unexpanded results in bash-running-in-vscode with echo $PATH, but running outside of vscode works fine

      • I just set VScode to always run in admin mode
      • See GH issue

Cmder - new tab spawns multiple duplicates

I tend to run into an issue every once in a while with "open new tab" spawning multiple duplicate previous tabs in cmder

  • Seems to happen when there is no "default task for new console"

    • Go into "Settings -> Startup -> Tasks" and then pick a task, such as "{cmd::Cmder as Admin}" and check the box for "Default task for new console"

Cmder - open new tab as admin

-new_console:a

Credit

Productivity

Make sure to check out my favorite programs page.

Here are some additional productivity tips / tricks / tools:

  • Don't forget about "scaffolding"

    • If you find yourself writing a lot of boilerplate, check to see if someone else has already created a template file, or better yet, a scaffolding tool that can generate the basic structure
    • If it doesn't exist, that is a great opportunity to create one and share it with the world!
    • Check out tools like Yeoman, which are industry standard for scaffolding new apps / codebases. Yeoman covers over 5K generators!
  • Online codeplaygrounds are great for sharing demos with others, or even just testing little ideas without needing to fire up your IDE, setup a git repo, etc.
  • Written documentation and guides are great, but don't forget about alternative media, such as YouTube.

    • On YouTube, you can also usually speed up videos by 1.5x or 2x and still be able to understand and learn from it; great time saver!
    • Lots of new tech podcasts coming on as well; these tend to cover broader tech education, rather than a step-by-step guide on how to do xyz.
  • Answering questions on StackOverflow can be a good way to brush up on certain skillsets or make sure they stay fresh.
  • Automate!

    • There is a great XKCD chart on whether something is worth the time to automate
    • I would add to this that you should also think about the time saving for others if you share your automation. Could it add to your resume / portfolio, and maybe even get you a job? Or just feel nice about helping others? What is that worth?
  • Take advantage of the open-source repos as a learning tool

    • If you ever wonder "how do the pros do ____?", you should take a look at some Open-Source software that matches what you are looking for.
    • For example, when I was trying to learn some QT and figure out how to structure my project directories (something often glossed over), I realized I could just look at the source for the actual QT IDE to see how QT themselves structured what has to be one of the largest QT projects ever!
    • Chromium and Firefox are both Open-Source and easily navigated online, and both cover a huge amount of different programming uses

Enforcing coding standards / editor configs

A lot of this is specific per language (for example, see js-devops) or per IDE (see vscode), but there are some general tips that are true across languages.

For example, EditorConfig files (.editorconfig) are a cross-IDE solution for declaring some general coding style rules for a given directory/repo, such as tabs vs spaces. On some IDEs, such as WebStorm, it is natively supported, whereas with others, such as Visual Studio Code, a plugin is necessary.


Docker

Resources

What Type Link
Base Commands - Quick Ref Reference docs.docker
Compose - getting started Tutorial docs.docker
Compose - getting started Tutorial fedoraproject
Compose Guide (Heroku) Guide Heroku
Example of a YAML config for a complex backend/frontend docker setup Tutorial freecodecamp
Devhint Cheatsheet Reference devhints.io

Basic Commands

What Command Helpful Flags
List active containers docker ps --all
Restart a container docker restart {containerName}
Stop a container docker kill {containerName}
Inspect something docker inspect {thingIdOrName}
View logs docker logs {?:containerName} -f follow
-tail
--details show extra detail
Execute a command inside a container docker exec {containerName} -i interactive
-t allocate TTY
-d detach
List volumes docker volume ls
Drop volume docker volume rm {volumeName} -f or --force
List version docker version
Pull an image docker pull {imageName}
Run an image docker run {imageName}

Example: docker run hello-world
--name (give container a short name)

Note: For most of the commands that take an image name, you can optionally request a specific tag or digest version of an image by using a special suffix. For example, {imageName}:{tag} or {imageName}@sha256:{digestSha}

docker-compose is listed below, in its own section

Docker Compose (aka docker-compose) commands

CLI Overview: https://docs.docker.com/compose/reference/overview/, or use docker-compose --help Composer YML file overview: https://docs.docker.com/compose/compose-file/

There are common flags that can be applied with any subcommand. For example: -f or --file lets you specify a docker .yml file other than the default of docker-compose.yml.

What Command Helpful Flags
Test out a config docker-compose config
Stop containers, without removing docker-compose stop
Stop and remove containers docker-compose down -v: remove named volumes
Build and launch container docker-compose up -d (starts in detached mode)
--force-recreate
Removed stopped containers docker-compose rm If you don't pass a name, it removes all (like rm *)
-v removes the volumes as well. Useful if something is persisting when you don't want it to and need a hard reset.
-f : Force
Validate a config without running it docker-compose config -q - Quiet mode, only validates true/false without verbose output
Show logs docker-compose logs -f follow
--tail={#} Tail lines
You can also pass the container name - docker-compose logs {containerName}

Docker-Compose syntax and options

  • You can use environment values within your docker-compose file (variable substitution)

    • Syntax is ${VARIABLE_NAME} (just like JS template literal), or $VARIABLE_NAME
    • The .env file has to be in the same directory as the docker-compose.yml file (see 1, 2)

      • Depending on your version of docker-compose, you might be able to get around this with either --project-directory (ref) or --env-file (ref), however, I have not had success with either so far
  • You can pass environment values to the container itself

    • Full details

      • You can use the env_file option to pass an entire .env file contents to the container
      • Put under environment: but leave off value
      • Pass via docker-compose run -e {VAR}={VAL} {imageName}

Volume types options / drivers

See: https://docs.docker.com/storage/storagedriver/select-storage-driver/

Type Description
tmpfs Temp data, stored in memory, not persisted between sessions
btrfs Advanced, persisted storage. Requires a bunch of pre-reqs, including Linux Kernel support.
nfs Shared, persisted storage

How do i...

How do I...

  • List active containers

    • docker ps
  • Get a container IP address

    • docker inspect {containerName}
    • Just IP address:

      • docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id
      • Use double quotes if you have issues.
      • Credit: S/O
  • Debug a container not starting correctly (die event)

    • See this S/O - Summary: - Start event logger with docker events& - this kind of does tail - Do "thing" - e.g. up, that triggers error - You should see error appear in event log - Copy error instance ID from event log and use with docker logs {eventId}
  • Access BASH inside container

    • docker exec -ti {containerName} bash

      Issues

  • PostgreSQL issues with Windows - usually due to permissions issue

  • Can't remove volume (even with -f or --force): "Error response from daemon: remove {volume}: volume is in use"

    • Try this first:

      • docker-compose down -v (or docker-compose rm -f -v)
    • If the volume is being locked by a container, you can find what is using it:

      • `docker ps --filter volume={volume}

Virtual Box

  • Reminders:
  • You can install guest additions via device menu, and then install into guest

    • This might be necessary to share folders
Markdown Source Last Updated:
Sun Nov 17 2019 04:07:18 GMT+0000 (Coordinated Universal Time)
Markdown Source Created:
Sat Sep 14 2019 22:52:46 GMT+0000 (Coordinated Universal Time)