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
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
- Override named container with -oc or --override-container parameter · Issue #22811 · moby/moby
--workdir
- How inheritance works,
- go-ethereum/Dockerfile at master · ethereum/go-ethereum · GitHub
- Custom entry point scripts
- Running a custom script using entrypoint in docker-compose - Stack Overflow
- Better volume documentation
- Use volumes | Docker Documentation
- CIFS
- NFS
- SSH!?!?!
- Custom networking
- Provide static IP to docker containers via docker-compose - Stack Overflow
- dockerfile examples
- troubleshoot/Dockerfile · master · Paul Mullins / DentropyCloud · GitLab
- Docker compose external volume path - Stack Overflow
- NFS or SMB and which method : docker
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 Links
- How to Transfer/Move a Docker Image to Another System?
- How to pass arguments to entrypoint in docker-compose.yml - Stack Overflow
Docker NFS Research
- NFS does not work with sqlite
- May have to edit the containers themselves because NFS does not support changing permissions
- NFS Daemon must be installed - 12.04 - NFS kernel daemon: no support in current kernel - Ask Ubuntu
- FreeNAS has special settings I don't know about
- https://github.com/ehough/docker-nfs-server/issues/2
- https://container42.com/2014/03/29/docker-quicktip-4-remote-volumes/
Links
Install Docker
- Windows / WSL2
- Install Docker Desktop on Windows | Docker Documentation
- Mac
- Install Docker Desktop on Mac | Docker Documentation
- Linux
- docker/docker-install: Docker installation script
Testing Docker
docker run hello-world
docker run -t -i -p 127.0.0.1:8080:8080 zadam/trilium:0.48-latest