EngineeringWiki
  • Introduction
  • Top level Overview of the application
  • FAQs
  • Back End
    • Agent Pipeline
    • Mention Pipeline
    • Profile Pipeline
    • Errors
    • Overview of the Mention/Profile/Cluster Process
    • Adding a New Service
    • Activity and Status Tracking
  • Setup
    • Overview
    • How to Setup Your Local Machine
    • Setup - Cloud Machine
    • Infrastructure
    • Docker
    • Bash Commands
    • Setting up front end in Ubuntu 16.04 desktop
  • Gems/Libraries
    • Bax
    • Creating fixtures for Unit Tests
    • Audienti-Retriever
    • Scour
    • Haystack
    • Audienti-Indexer
    • Audienti-Api
    • Handler
    • Blackbook
    • Allusion
  • Code
    • Multi-step Modal Wizard
    • Structure
    • Audienti DataTables
    • Javascript
      • Passing Props From Root
      • Looping in JS
      • Binding Actions to App
      • CSSTransitionGroup
      • Code Best Practices
      • Reducer Updating an Array with Item in Middle
      • Organizing Javascript
      • Filter Array by Id
    • Design Language
  • Working
    • PostgresSQL
    • S3
    • Terminology
    • Interview Tests
    • Application Descriptions
    • Best Practices
      • Code Organization
      • Code Documentation (using Yard)
      • Git Workflow
      • Tasks and Queues
      • Working in Backend
    • Profiles & Enrichment
      • Profile ID Rules
  • Management
    • API Management
    • Bastion
    • Splash Proxy
    • Rancher
      • OpenVPN Server
      • Traefik Reverse Proxy
  • Teams & Interviews
    • Interview Questions
  • Culture
    • What Makes a World Class Engineer
  • Situational Statuses
    • 2017-11-03
    • 2018-01-09
  • Operations
Powered by GitBook
On this page
  • Cleaning up
  • Nuke
  • Remove files matching a name.
  • Start/Stop
  • Docker compose
  • Inspecting a Stopped Container
  1. Setup

Docker

Cleaning up

Cleanup the docker virtual disk for images that are partial stages from builds:

function dcleanup {
    docker rm -v $(docker ps --filter status=exited -q 2>/dev/null) 2>/dev/null
    docker rmi $(docker images --filter dangling=true -q 2>/dev/null) 2>/dev/null
}

Nuke

To wipe containers and images out and start fresh. This has to happen from time to time, as Docker uses a virtual disk that has a fixed size, usually between 15Gb and 80Gb. This is shown as a function so it can be copied into your .bashrc if you want to do so.

function dnuke {
  docker stop $(docker ps -a -q)
  docker rm $(docker ps -a -q)
  docker rmi $(docker images -q)
  docker ps -a | sed '1 d' | awk '{print $1}' | xargs -L1 docker rm
  docker images -a | sed '1 d' | awk '{print $3}' | xargs -L1 docker rmi -f
  docker volume rm $(docker volume ls -qf dangling=true)
  echo "Nuked!"
}

Remove files matching a name.

This will remove anything that text matches a term you enter on the function.

function dremovebyname {
    docker ps -a | awk '{ print $1,$2 }' | grep $1 | awk '{print $1 }' | xargs -I {} docker rm -f {}
}

Start/Stop

Stopping docker containers running.

# stops all your continers
function dockerstop {
  docker rm $(docker stop $(docker ps -a -q --filter ancestor=$1 --format="{{.ID}}"))
}

Docker compose

To issue commands with docker-compose, you need to be in the root folder of that drive (that contains the docker-compose.yml files). Otherwise, your results MAY vary. You cannot issue docker-compose commands from INSIDE a container.

To stop everything without deleting all the data:

docker-compose stop

To stop everything AND delete all the data (the database is the thing that matters here).

docker-compose down

Inspecting a Stopped Container

Inspecting a stopped container's file system is a thing that needs to be done from time to time. To do this:

docker commit CONTAINER_ID NEWIMAGENAME
docker run -ti --entrypoint /bin/bash NEWIMAGENAME
PreviousInfrastructureNextBash Commands

Last updated 7 years ago