install
# docker
apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y
systemctl start docker
systemctl enable docker
docker --version
docker info
# docker-compose
curl -L "https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose --version
docker commands
# list
docker ps [-a]
# search by name
docker ps [-a] | grep "redis"
# logs
docker logs -f --tail <container-name>
# start/stop/rm
docker start/stop/rm <container-name>
# container info
docker inspect <container-name>
# disk usage
docker system df
network
# create
docker network create --subnet 10.10.10.0/24 net-stmp
# delete
docker network prune
docker-compose commands
# up
docker-compose up -d [--build] [<service-name>]
# down
docker-compose down
# logs
docker-compose logs -f --tail=0 <service-name>
# list
docker-compose ps
images
# images
docker images | grep nginx
# save
docker save -o nginx.1.24.0.tar redis:1.24.0
# load
docker load -i nginx.1.24.0.tar
# delete the image with the tag none
docker images | grep none | awk '{print $3}' | xargs docker rmi