Resource: Docker

Links

// set variable
export POSTGRES_PASSWORD='password'

// use it later
docker run -e POSTGRES_PASSWORD -e POSTGRES_USER ...

Logs

  docker logs infrastructure-rabbitmq-1
#   or
  docker logs d3387e01e7cd

List containers

docker ps
# or
docker container ls -a

Remove specific container

docker rm d3387e01e7cd
  • docker stop also works with container id

Get into container shell/terminal

docker exec [container-id or name] [shell - can be bash or ash]

Common flags

  • -it is short for interactive

Misc

  • Alpine is like a bare bones linux
  • docker image prune will clear up a bunch of space for you. But you’d have to rebuild images & such.

TIL: difference between attach & exec:

  • attach isn’t for running an extra thing in a container, it’s for attaching to the running process.
  • docker exec is specifically for running new things in a already started container, be it a shell or some other process. src
  • This could make for a good read