Skip to content

Instantly share code, notes, and snippets.

@rhiroyuki
Last active September 4, 2019 03:25
Show Gist options
  • Save rhiroyuki/a14f7ac7e8f7fcd48c6494a89f0fc7a4 to your computer and use it in GitHub Desktop.
Save rhiroyuki/a14f7ac7e8f7fcd48c6494a89f0fc7a4 to your computer and use it in GitHub Desktop.
dockerzing
# DOCKER
# Running docker without sudo:
sudo usermod -aG docker $USER
# You need to logout in order to apply the settings
# To get more information about each command and its parameters
# type $docker command --help
# ex: docker stop --help
# Stop all containers first
docker stop $(docker ps -aq)
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
# Show containers
# --all or -a (show stopped containers)
# without --all param only shows currently running containers
docker ps -a
# List images
docker images ls
# List containers
docker containers ls
# Creating container based on Dockerfile
# passing the tag will help to run this image
docker build --tag some/optional-tag .
# Running a stopped container
docker start CONTAINER_NAME
# Running
# --port (local:container)
docker run --name some/optional-tag -itd -p 22:22 -v ~/dev/php:/var/www/app flaviosilveira/php-nginx-2
docker run --name postgres11 -e POSTGRES_PASSWORD=root -e POSTGRES_USER=root -p 5432:5432 -d postgres:11.5
# RUN OR EXEC?
# Use :exec for an existing container
# Use :run when no container was created yet
# Managing containers
docker container --help
# Starting an existing container
docker container start ${CONTAINER_ID}
# Stopping a container
docker container stop ${CONTAINER_ID}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment