Skip to content

Instantly share code, notes, and snippets.

@scsskid
Last active February 15, 2023 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scsskid/befdccb81e3c623319ec096bebbda191 to your computer and use it in GitHub Desktop.
Save scsskid/befdccb81e3c623319ec096bebbda191 to your computer and use it in GitHub Desktop.
Docker Personal Cheatcheet | #bash #docker

Docker Personal Cheatsheet

remove all containers

docker rm -f $(docker ps -aq)

Get ip address of container

docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id

Testing Single Containers without compose

Random Examples:

# https://unix.stackexchange.com/a/79077

set -a \
source .env \
set +a

docker build --no-cache -t tlnodejsimage .

docker run \
  --name tlnodejscontainer \
  -d \
  --mount type=bind,source="$(pwd)",target=/home/node/app \
  --mount type=volume,source=node_modules_volume,target=/home/node/app/node_modules \
  -e "POSTGRES_USER=$POSTGRES_USER" -e "POSTGRES_PASSWORD=$POSTGRES_PASSWORD" -e "EXPRESS_PORT=$EXPRESS_PORT" \
  -p 5000:5000 \
  --network=tlnet \
  tlnodejsimage

docker run \
  --name tlpostgres \
  -d \
  -e "POSTGRES_USER=$POSTGRES_USER" -e "POSTGRES_PASSWORD=$POSTGRES_PASSWORD" \
  -v postgres_data_volume:/var/lib/postgresql/data \
  --network=tlnet \
  postgres
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment