# Docker Cheat Sheet ## Installation ### Quick Install Guide for Docker on Windows Go to the Docker website at https://www.docker.com/get-started and click on "Download for Windows". Follow the on-screen instructions to download the installer. Once the installer is downloaded, double-click it to start the installation process. Follow the prompts to install Docker on your system. You may be prompted to enable certain features, such as Hyper-V or virtualization. Once the installation is complete, open a command prompt or PowerShell window. Type the command `docker version` to verify that Docker is installed and working correctly. ## Basic Commands docker run <image>: Run a container from an image docker ps: List all running containers docker stop <container>: Stop a running container docker rm <container>: Remove a container docker images: List all available images docker rmi <image>: Remove an image ## Container Management docker exec -it <container> <command>: Run a command in a running container docker start <container>: Start a stopped container docker restart <container>: Restart a running container docker pause <container>: Pause a running container docker unpause <container>: Unpause a paused container ## Image Management docker build -t <tag> <path>: Build an image from a Dockerfile docker push <image>: Push an image to a registry docker pull <image>: Pull an image from a registry docker tag <source> <target>: Create a new tag for an image docker save <image> -o <file.tar>: Save an image to a file docker load -i <file.tar>: Load an image from a file ## Networking docker network create <name>: Create a new network docker network ls: List all available networks docker network inspect <name>: Inspect a network docker network connect <network> <container>: Connect a container to a network docker network disconnect <network> <container>: Disconnect a container from a network ## Docker Compose docker-compose up: Start containers defined in a Docker Compose file docker-compose down: Stop and remove containers defined in a Docker Compose file docker-compose logs: Show logs for containers defined in a Docker Compose file docker-compose exec <service> <command>: Run a command in a running service container docker-compose build: Build the services defined in a Docker Compose file # Git Cheat Sheet ## Basic Commands git init: Initialize a new Git repository git clone <url>: Clone a remote repository to your local machine git add <file>: Add a file to the staging area git commit -m "message": Commit changes with a message git status: View the status of your repository git log: View a log of your commit history ## Branching and Merging git branch: List all branches in the repository git branch <name>: Create a new branch with the given name git checkout <branch>: Switch to the specified branch git merge <branch>: Merge the specified branch into the current branch git rebase <branch>: Rebase the current branch onto the specified branch ## Remote Repositories git remote -v: Shows the current remote repository git remote add <name> <url>: Add a new remote repository with the specified name and URL git push <remote> <branch>: Push the current branch to the specified remote repository git pull <remote> <branch>: Pull changes from the specified remote repository to the current branch git fetch <remote>: Fetch changes from the specified remote repository ## Undoing Changes git reset <file>: Remove a file from the staging area git reset --hard: Discard all changes and revert to the last commit git revert <commit>: Create a new commit that undoes the changes made in the specified commit git stash: Stash changes and save them for later use git stash apply: Restore changes that were stashed using git stash