Docker Cheat Sheet or Useful commands
Download Latest Docker Engine using only one command (linux)
curl https://get.docker.com/ > dockerinstall && chmod 777 dockerinstall && ./dockerinstall
For Check Docker Version
docker -vfor Search available Docker images on Docker hub
docker search ubuntuPull Docker image from online docker hub
docker pull $imagename
docker pull ubuntu:18.04Note: In the OFFICIAL column, OK indicates an image built and supported by the company behind the project.
List all images in local docker engine
docker image lsRun Apache Docker container with web files mounted and port exposed
docker run --name web --restart always -v /my/own/datadir:/var/www/html -p 80:80 -d apache:latestlist all running containers
docker ps To list all running as well as stopped containers
docker ps -a Build Docker image in local environment from Dockerfile which is in current directory
docker build -t $imagename .
docker build -t apache-php .Tag Docker image with specified version number
docker tag $current_imagename:tag $new_imagename:$new_tag
docker tag apache-php:latest apache-php:1Push Docker image to registry
docker push $imagename:$tag
docker push apache-php:1Run commands inside running container
docker exec -it $containername bash
docker exec -it web bashIf you have made changes in container, which you want to store
docker commit -m "What did you do to the image" -a "Author Name" $containerid $repository/$new_image_name
docker commit -m "Changed Apache configuration rules" -a "IdenticalCloud" 03be8c21654c identicalcloud/apache:1Stop a running container
docker stop $containername
docker stop webDelete stopped container
docker rm $containername
docker rm webDelete running container
docker rm -f $containername
docker rm -f webTo remove docker image from local system
docker rmi $imagename
docker rmi apache:latestTo remove unwanted folders from stopped and deleted docker containers
This command will deleted all stopped containers, deleted container’s volume and logs, not used networks
docker system prune -a






0 comments:
Post a Comment