Skip to content

Instantly share code, notes, and snippets.

@mtigdemir
Last active December 24, 2020 19:56
Show Gist options
  • Save mtigdemir/115cf9a2d4d20f8194464907648577b5 to your computer and use it in GitHub Desktop.
Save mtigdemir/115cf9a2d4d20f8194464907648577b5 to your computer and use it in GitHub Desktop.
Docker Useful Commands

Docker describes themselves as "an open platform for developers and sysadmins to build, ship, and run distributed applications".

The key benefit of Docker is that it allows users to package an application with all of its dependencies into a standardized unit for software development. Unlike virtual machines, containers do not have the high overhead and hence enable more efficient usage of the underlying system and resources.

Most used Commands

// Pull Docker Image to Local

docker pull 

// Search Image on Docker Hub

docker search 

// Run Docker Image

docker run {imageName}

// Show Images on Local

docker images 

// Delete Images

docker rmi 

// Run Container on Background

docker run -d

// How to Run Apache and explain volume

docker run -d -p 80:80 --name my-apache-72 -v "$PWD":/var/www/html php:7.1-apache

docker run -p 1234:80 --name my-apache-71 -v "$PWD":/var/www/html php:7.2-apache

// Port and Naming Containers

docker run -d --name redisHostPort -p 6379:6379 redis:latest

// List of containers docker ps -a

// PHP Docker Container https://hub.docker.com/_/php/

## Stop All Containers
docker container stop $(docker container ls -aq)
## Remove all stopped containers.
docker rm $(docker ps -a -q)
## Remove all untagged images
docker rmi $(docker images | grep "^<none>" | awk "{print $3}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment