v1.0.0

Docker

# Install Docker

Check update system

sudo dnf -y update

Install Docker repository

sudo dnf install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Install Docker & Docker compose service

sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Enable and start Docker service

sudo systemctl enable docker --now

Execute Docker without sudo

sudo usermod -aG docker $(whoami)

# How to use

Docker build an image

docker build -t {image_name} .

Docker run an image

docker run -d -v .:{virtual_path} -p {real_port}:{container_expose_port} {image_name}

# Remove something in Docker

  • Container

    Docker remove a container

    docker stop {container_id|container_name}
    docker rm {container_id|container_name}

    Docker remove unused containers

    docker container prune

    Docker remove all containers

    docker stop $(docker ps -q)
    docker rm $(docker ps -a -q)
  • Image

    Docker remove an image

    docker rmi {image_id|image_name}

    Docker remove dangling images

    docker image prune

    Docker remove all images

    docker image prune -a
  • Volume

    Docker remove volumes

    docker volume prune
  • Network

    Docker remove networks

    docker network prune
  • Everything

    Docker remove containers, images and networks

    docker system prune

    Docker remove containers, images, networks and volumes

    docker system prune --volumes

# Docker remove build cache

Docker remove build cache

docker builder prune