Skip to content

rala4354/Docker_Cheats

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

Docker_Essential_Cheats

  1. Pulling an image from the repository
docker pull <name_of_the_image>
  1. To build an image from a Dockerfile
docker build -t <image_name> .

Note

Here . (optional) means current folder and -t (optional) is used to tag the image id. Both are optional.

  1. List all local images
docker images 
  1. Delete an image.
docker rmi <image_name> 
  1. Remove all unused images
docker image prune
  1. Publishing an image into Docker
docker push <username>/<image_name> 
  1. Running a container
docker run -t -d -p <host_port>:<container_port> --name <name_of_the_container> <image_name>

Important

-t tag (optional) is used to tag,
-d detach (optional) to run in the background not to show log details and terminal detach from running container,
-p <host_port>:<container_port> publish (optional) binding container port to the localhost.

  1. To open the shell inside the running container
docker exec -it <container_name> sh
  1. Check all the running containers
docker ps 
  1. List the containers that ran and exited successfully.
docker ps -a 
  1. Pings application
docker localhost
  1. Stops one or more running containers
docker stop

Tip

To stop all running containers

docker stop $(docker ps -q)

13.To remove a container

docker container rm 
  1. To see how much memory using by the containers
docker stats 
  1. Creates a tag for a target image that refers to a source image
docker tag
  1. Start the docker daemon
docker -d 

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published