Skip to content

docker

docker logging drivers

Stop and Remove ALL Docker Containers

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


sudo docker stop $(sudo docker ps -a -q)
sudo docker rm $(sudo docker ps -a -q)

Docker: How to Stop and Remove All Containers at Once | CloudBees

Remove all exited containers

docker ps -a | grep Exit | cut -d ' ' -f 1 | xargs sudo docker rm

# Created
docker ps -a | grep Created | cut -d ' ' -f 1 | xargs sudo docker rm

Install

sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo apt-get -y install docker-compose
sudo apt-get install iptables
sudo systemctl start docker
sudo systemctl enable docker
sudo usermod -aG docker $USER

Install Docker Engine on Debian | Docker Documentation Run Docker as a non-root user – The Geek Diary

Measure RAM

docker ps -q | xargs  docker stats --no-stream

How to See Memory and CPU Usage for All Your Docker Containers on CentOS 6 | Christopher J. McClellan

Get IP Address

docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id

How to get a Docker container's IP address from the host - Stack Overflow

How to upload to dockerhub

# Add repo on docker account
docker login
docker push {username}}/{repo name}}

Backlog - TODO

Outline

  • Create a docker container with a volume
  • Jump inside docker container and fuck with the volume
  • Backup volume
  • Delete volume
  • Restore container and volume

Create container with volume

docker volume create testvol
docker volume ls
docker volume inspect testvol
docker run -it \
    --name voltest \
    -v testvol:/testvol \
    ubuntu:latest
echo "I Like Pie" > /testvol/test.txt
cat /testvol/test.txt
# Should say "I Like Pie"
exit

Backup the docker volume to a tar file

docker stop voltest
mkdir ~/tmp-docker-backup 
docker run --rm --volumes-from voltest \
  -v ~/tmp-docker-backup:/backup ubuntu bash \
  -c "cd /testvol && tar cvf /backup/docker-vol-backup.tar ."

Remove the docker container and volume

docker rm -f voltest
docker volume rm testvol
docker ps -a
docker volume ls

Restore the docker volume and container

docker volume create testvol2
docker run --rm -v testvol2:/recover -v ~/tmp-docker-backup:/backup ubuntu bash -c "cd /recover && tar xvf /backup/docker-vol-backup.tar"
docker run -it \
  --name voltest2 \
  -v testvol2:/testbackup \
  ubuntu
ls /testbackup
cat  /testbackup/test.txt
exit
docker rm -f voltest2
docker volume rm testvol2
rm -r ~/tmp-docker-backup

Docker NFS Research

Install Docker

Testing Docker

docker run hello-world
docker run -t -i -p 127.0.0.1:8080:8080 zadam/trilium:0.48-latest

wiki.software.List.DiscordChatExporter