Skip to content

Instantly share code, notes, and snippets.

@ankittyagii
Last active December 27, 2019 14:49
Show Gist options
  • Save ankittyagii/0f865fccc00f3b50a04baa99173b5f87 to your computer and use it in GitHub Desktop.
Save ankittyagii/0f865fccc00f3b50a04baa99173b5f87 to your computer and use it in GitHub Desktop.
1 . cd c:/program files/docker/docker
.\dockercli -Version
TO check the CLI vrsion
2. docker image ls - List out the images from docker host
3. docker container ls - list out the active container
4. docker system info
5. docker-compose --version
6. docker-machine --version
7. notary --version
8. docker container run -it ubuntu:latest /bin/bash
* -it - means attaching exisiting shell with the container shell
9. docker container exec -it ubuntu:latest /bin/bash
* attaching the container with running command with exec command
10. docker container stop "Name of container"
11. docker container rm "Name of container"
12. docker container ls -a (list out all container and and also check whther the container is in the stopped state)
13. docker container run -d --name web1 --publish 8080:80 test:latest
14. docker image build -t test:latest
15. docker image pull ubuntu:latest
16. docker image pull <repos>:<tag>
17. docker image pull -a ubuntu - it will download all the images with different tag
18. docker image ls --filter dangling=true ( --filter tag will return the list of images from docker image. A dangling is an image that is no longer tagged)
19. docker image ls --filter=reference="*:latest" ( it will filter out the image with latest tag)
Docker currently support 4 filters
1. Dangling
2. before
3. since
4. label
docker image ls --filter since=test
docker image ls --filter before=test
docker image ls --filter dangling=true or false
docker image ls --filter label="This is my repository"
20. docker image ls --format "{{.Size}}" ( - Return output as the image size)
Output
71.5MB
5.55MB
212MB
21. docker image ls --format "{{.Repository}}:{{.Tag}}:{{.Size}}"
Output
test:latest:71.5MB
alpine:latest:5.55MB
nigelpoulton/tu-demo:v2:212MB
22. docker search ankittyagi366 ( display list of images with the docker hub account ankittyagi366).
23. docker search alpine --filter "is-official=true" ( Return the offical image of alpine )
24. docker search alpine --limit=30 ( display the images of alpine with limit of 30 . Note maximum limit will be 100)
25. docker image inspect ubuntu:latest ( display the json file contains all information like layers of an image and many more)
26. docker swarm init --advertise-addr <ip> --listen-addr <ip> - Initilize the swarm in docker
27. docker swarm join-token worker - Give you a token which help other nodes to join as a worker
28. docker swarm join-token manager - give you a token which help other nodes to join as a manager
29. docker swarm update --autolock=true - locking the swarm so no one can add or remove workers and manager from swarm
30. docker service create --name <nameofservice> -p <port like 80:8080> --replicas <no of replicas for the service> - create service with no of replication
31. docker node ls - list out all the nodes in the swarm
32. docker service ls- view all services running on swarm
33. docker service scale <service-name>=<no of replicas> - for scalling the service to n no of replicas
34. docker service rm <servicename/id> - remove service from the swarm
35. docker-compose --version - give you the version of docker compose
36. docker-compose up & - It build all the required images, create all required network and volumes and starts all required container
& - > if you bought the application up using the & you will be able to see the HTTP 200 response codes being logged in the terminal window
37. docker-compose -f prod-compose.yml up - Note -f - if you compose file has different name so you need to specify this flag
38. docker-compose down - stop network and all container which is running when we up the command. note - only images & volumes never deattach using this command it will still be there.
39. docker network ls - list out the network available
40. docker volume ls - list out all the volumes attached to the containers.
41. docker-compose restart - restart the app again
42. docker-compose up -d - run the app in background if we use -d flag
43. docker-compose ps - show the current state
44. docker-compose top - list the process running inside of each service/container
@ankittyagii
Copy link
Author

Added docker-compose and swarm commands

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment