Skip to content

Instantly share code, notes, and snippets.

@fabiorecife
Last active November 5, 2021 09:21
Show Gist options
  • Select an option

  • Save fabiorecife/dda0de9e985c31b08df390f3d8209a75 to your computer and use it in GitHub Desktop.

Select an option

Save fabiorecife/dda0de9e985c31b08df390f3d8209a75 to your computer and use it in GitHub Desktop.
docker commands

Release docker use without sudo

sudo usermod -aG docker $(whoami)

Commands

  • docker ps # displays all currently running containers
  • docker ps -a # displays all running and stopped containers
  • docker start ID_CONTAINER # starts the container with the entered id
  • docker stop ID_CONTAINER # stop the container with the entered id
  • docker exec -u 0 -it ID_CONTAINER "bash" # run bash in a running container
  • docker rm ID_CONTAINER # remove container
  • docker container prune # remove all containers
  • docker rmi IMAGE_NAME # remove image
  • docker run -d -p HOST_PORT:CONTAINER_PORT --name NAME username/image_name:tag
  • docker network create --driver bridge NETWORK_NAME # create bridge-type network
  • docker run -it --name CONTAINER_NAME --network NETWORK_NAME # create container on network NETWORK_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment