docker pull mysql
docker stop my-mysql-container
docker rm my-mysql-container
docker run --name=my-mysql-container --restart=always \
-e MYSQL_ROOT_PASSWORD=mypwd -v /my/data/dir:/var/lib/mysql -d mysql
Connect to host http://host.docker.internal
View logs for last 500 lines and follow
docker logs -f --tail=500 <container name>
SSH into container
docker exec -it <container name> /bin/bash
Bring up docker image that will remove its self upon exiting shell
docker run --rm -it ubuntu:16.04 bash -l
Found this info in a great blog post
df -h
docker ps
docker images
docker volume rm $(docker volume ls -qf dangling=true)
delete orphaned and dangling volumesdocker rmi $(docker images -q -f dangling=true)
delete dangling and untagged images
docker rm $(docker ps -aqf status=exited)
delete exited containersdocker rmi $(docker images -q)
delete all imagesdocker kill $(docker ps -q)
kill all running containersdocker rm $(docker ps -aq)
delete all running containers
docker system prune -a
sudo usermod -aG docker $USER
Run this script in a cron job
#!/bin/bash
docker rmi $(docker images -q -f dangling=true)
docker volume rm $(docker volume ls -qf dangling=true)
cron job:
15 0 * * 1 ~/docker-cleanup.sh > /dev/null 2>&1