# Remove previous installs
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
# Install docker
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin Pls dont use this
## PLS DONT USE THS
# for debian/ubuntu users
sudo apt update
sudo apt install docker.io
# for fedora users
sudo dnf install docker
# for arch users
sudo pacman -S dockerRunning docker daemon
sudo systemctl enable --now docker.service
For adding user to docker group
sudo usermod -aG docker $USER- HELP π
 
docker help- Current running docker processes (containers) π
 
docker ps
docker ps -a-a--> to get all the running containers-q--> to get just the container id
- Stopping and Removing π
 
docker stop [container_id]
docker rm [docker_id]docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)- For building docker image ποΈ
 
docker build -t [image_name] [dir_of_Dockerfile]- For creating & running docker image π
 
docker run --nane [container_name] [image_name]- can add 
-rmfor stooping and removing docker as u exit - can add 
-dfor detaching it from terminal after running (if ur using default bridge network) - add 
-p [host_port]:[docker_port]for mapping a specific docker port to host port 
- For executing something inside docker image π±οΈ
 
docker exec [file/command_wanna_run] [container_name]- KILL IT πͺπ
 
docker kill [container_id]- Logs π
 
docker logs [container_id]- Pull
 
docker pull [image_name]:[tag]- list of docker image
docker image ls
 
- Tag
 
docker tag [image_id] [image_name]:[tag]- Push
 
docker push [image_name]:[tag]    # default tag is "latest"- create
 
docker volume create [volume_name]- manage
 
docker volume list
docker colume inspect [volume_name]- mount
 
# for mounting docker volume 
docker run -v [volume_name]:[path_in_container] [docker_image]
# for mounting host directry
docker run -v "[host_directry]":[volume_name] [docker_image]- remove
 
docker volume rm [volume_name]
docker volume prune   # to remove all unused volumes- Creating network
 
docker network create [network_name]- Connect
 
docker network connect [network_name] [container_name]- Disconnect
 
docker network disconect [network_name] [container_name]- List & Inspect
 
docker network ls
docker inspect [network_name]- Delete network
 
docker network rm [network_name]
doceker network prune    #delete all unused network- macvlan
 - ipvlan
 - overlay
 
(There are other possible P&C too....)
--subnet 172.76.0.0/16--> to define subnet--gateway 172.76.0.1/16--> to define the gateway of the network-o parent=[network_interface]--> to define the physical network interface
It's the default one no need for any flags.
docker network create [network_name]
docker run --network [network_name] [container_id] [image_name]docker run --network host [container_id] [image_name]docker run --network none [container_id] [image_name]- Instalation
 
Create a docker voume or direct mount to a host directry
docker volume create portainer_dataRun the portainer as a contatiner on the bridge network
docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:2.21.5Sample docker-compose
---
services:
  portainer:
    image: portainer/portainer:latest
    container_name: portainer
    environment:
      - PUID = ${UID}
      - PGID = ${GID}
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ${DATA}:/data
    ports:
      - 8000:8000
      # - 9000:9000 #HTTP port
      - 9443:9443 #HTTPS port
    restart: always
Common tags:
FROM--> Base imageCOPY--> Commands to runWORKDIR--> current working dir in the containerEXPOSE--> expose the mentioned portCMD--> run the final service (should not have a terminatig shell)
Common paramaters:
- service
  - [service-name]
    - image: [image_name]
    - container_name: [any_name_for_container]
    - hostname: [hostname]
    - user: [GID]:[UID]
    # - env_file:
    #   - [.env_location]
    - environment:
      - [parameter]=[value]
    - volumes:
      - [host_location]\:[container_location]
    - ports:
      - [host_port]\:[container_port]
    - restart: [always, unless-stopped, ....]