Last active
March 14, 2021 15:45
-
-
Save alicoskun/5b4b2618753c6b2befe88c15e0580623 to your computer and use it in GitHub Desktop.
useful docker commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker build -t dockerapi . | |
docker run --name dockerapi -p 8000:80 dockerapi:latest | |
docker image ls | |
docker image prune | |
docker system prune | |
docker container ls | |
docker logs --since=1h <container> // use -f or --follow to view logs realtime | |
docker logs --tail 20 <container> | |
docker commit 44159fc64fde alicoskun/cloud-sample | |
docker push alicoskun/cloud-sample | |
docker pull alicoskun/cloud-sample | |
docker rm 8f825fe34bf8 //remove container | |
docker image rm 4119b06ba08b //remove image | |
docker-compose -f docker-compose.prod.yml up -d --build | |
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d --build | |
// copy file into docker container | |
docker cp preview.png tip-container-webapp:/app/wwwroot/uploads/alicoskun/business-office-c167b2f2/preview.png | |
You can bring everything down, removing the containers entirely, with the down command. Pass --volumes to also remove the data volume used by the Redis container: | |
docker-compose down --volumes | |
// ssl certificates | |
// port 80 must be unallocated | |
// disable cloudflare | |
certbot certonly --nginx | |
certbot renew | |
certbot certificates | |
certbot renew --renew-hook "docker restart container-name" | |
certbot certonly --nginx --dry-run | |
certbot renew --dry-run | |
// renewal config file path /etc/letsencrypt/renewal/ | |
// to create certificate manually | |
sudo certbot certonly --standalone --preferred-challenges http -d example.com -d www.example.com | |
sudo certbot certonly --standalone --preferred-challenges http -d example.com -d www.example.com --dry-run | |
docker restart <<nginx-container-name>> | |
// listening ports | |
netstat -ntlp | grep LISTEN | |
kill -9 <pid> | |
// made from local!!! | |
// migrations | |
Add-Migration AddProductReviews | |
dotnet ef migrations add AddProductReviews | |
Update-Database | |
dotnet ef database update | |
Script-Migration | |
dotnet ef migrations script | |
echo -n password | sha256sum | |
// by @Gökhan Şengün -> https://gokhansengun.com/ | |
docker images Lokal registry’de mevcut bulunan Image’ları listeler | |
docker ps Halihazırda çalışmakta olan Container’ları listeler | |
docker ps -a Docker Daemon üzerindeki bütün Container’ları listeler | |
docker ps -aq Docker Daemon üzerindeki bütün Container’ların ID’lerini listeler | |
docker pull <repository_name>/<image_name>:<image_tag> Belirtilen Image’ı lokal registry’ye indirir. Örnek: docker pull gsengun/jmeter3.0:1.7 | |
docker top <container_id> İlgili Container’da top komutunu çalıştırarak çıktısını gösterir | |
docker run -it <image_id|image_name> CMD Verilen Image’dan terminal’i attach ederek bir Container oluşturur | |
docker pause <container_id> İlgili Container’ı duraklatır | |
docker unpause <container_id> İlgili Container pause ile duraklatılmış ise çalışmasına devam ettirilir | |
docker stop <container_id> İlgili Container’ı durdurur | |
docker start <container_id> İlgili Container’ı durdurulmuşsa tekrar başlatır | |
docker rm <container_id> İlgili Container’ı kaldırır fakat ilişkili Volume’lara dokunmaz | |
docker rm -v <container_id> İlgili Container’ı ilişkili Volume’lar ile birlikte kaldırır | |
docker rm -f <container_id> İlgili Container’ı zorlayarak kaldırır. Çalışan bir Container ancak -f ile kaldırılabilir | |
docker rmi <image_id|image_name> İlgili Image’ı siler | |
docker rmi -f <image_id|image_name> İlgili Image’ı zorlayarak kaldırır, başka isimlerle Tag’lenmiş Image’lar -f ile kaldırılabilir | |
docker info Docker Daemon’la ilgili özet bilgiler verir | |
docker inspect <container_id> İlgili Container’la ilgili detaylı bilgiler verir | |
docker inspect <image_id|image_name> İlgili Image’la ilgili detaylı bilgiler verir | |
docker rm $(docker ps -aq) Bütün Container’ları kaldırır | |
docker stop $(docker ps -aq) Çalışan bütün Container’ları durdurur | |
docker rmi $(docker images -aq) Bütün Image’ları kaldırır | |
docker images -q -f dangling=true Dangling (taglenmemiş ve bir Container ile ilişkilendirilmemiş) Image’ları listeler | |
docker rmi $(docker images -q -f dangling=true) Dangling Image’ları kaldırır | |
docker volume ls -f dangling=true Dangling Volume’ları listeler | |
docker volume rm $(docker volume ls -f dangling=true -q) Danling Volume’ları kaldırır | |
docker logs <container_id> İlgili Container’ın terminalinde o ana kadar oluşan çıktıyı gösterir | |
docker logs -f <container_id> İlgili Container’ın terminalinde o ana kadar oluşan çıktıyı gösterir ve -f follow parametresi ile o andan sonra oluşan logları da göstermeye devam eder | |
docker exec <container_id> <command> Çalışan bir Container içinde bir komut koşturmak için kullanılır | |
docker exec -it <container_id> /bin/bash Çalışan bir Container içinde terminal açmak için kullanılır. İlgili Image’da /bin/bash bulunduğu varsayımı ile | |
docker attach <container_id> Önceden detached modda -d başlatılan bir Container’a attach olmak için kullanılır | |
// on windows | |
// to access container with ip address run this code as administrator on cmd | |
// check 172.29.0.0 from "docker container inspect container_name" | |
route add 172.29.0.0 MASK 255.255.0.0 10.0.75.2 | |
// reboot droplet | |
sudo shutdown -r now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment