Skip to main content

Docker Basics

Install docker with script

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

Manage Docker as a non-root user

The docker group grants privileges equivalent to the root user.

  1. Create the docker group.
sudo groupadd docker
  1. Add your user to the docker group.
sudo usermod -aG docker $USER
  1. Log out and log back in so that your group membership is re-evaluated.

Configure Docker to start on boot

sudo systemctl enable docker

List all containers (only IDs)

docker ps -aq

Stop all running containers

docker stop $(docker ps -aq)

Remove all containers

docker rm $(docker ps -aq)

Remove all images

docker rmi $(docker images -q)

Checking logs of container

docker logs <container id>

for live log pass -f or --follow

docker logs -f <container id>