Skip to content

5AbhishekSaxena/docker_notes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Docker Notes

Contains a list of simple docker commands.

Toable of Content

  • docker images List all the docker images.

  • docker ps List all the running containers.

  • docker ps -a Lists all the containers runnning + stopped

  • docker pull <image_name>:<version> Pull the image from Docker hub of the specified version

  • docker pull <image_name> Same as before but teh version is "latest" which is the default version is pulled from the DockerHub.

Run a container Back ⇈

  • docker run <image_name>:<tag> Runs the container for the docker image. Please note:
  1. Docker will look for the image locally, and if not found then it will look for it in the docker hub. If found, it will pull it and then run it.
  2. It creates a new container each time.
  • docker run -d <image_name>:<tag> Runs the container in detached mode. The process is not blocking the terminal. The container runs in the background.

  • docker run -d -p <local_machine_port>:<application/docker container_port> <image_name>:<tag> Port binding - Binds the container to a port on the local machine so it can be accessed.

  • docker run --name web-app -d -p <local_machine_port>:<application/docker container_port> <image_name>:<tag> flag --name It is used to give a custom name to the container.

  • docker start <container_id> or <container_name> Restarts the exited/stopped container.

  • docker stop <container_name> or <container_id> Stops the container with the given id or name.

  • docker logs <container_id> or <container_name>` View logs of the container.

Build Back ⇈

  • docker build -t <image_name>:<tag> . // or --tag = and "." refers to the current folder build a custom docker image.

Clean up Back ⇈

  • docker container prune Delete all the stopped containers

  • docker image rm <image_name>:<tag> Delete the docker image

About

Contains a list of simple docker commands.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published