Skip to content

Instantly share code, notes, and snippets.

@Neeraj1005
Created January 8, 2024 11:46
Show Gist options
  • Save Neeraj1005/0498677584960fe6130176c00dbc247c to your computer and use it in GitHub Desktop.
Save Neeraj1005/0498677584960fe6130176c00dbc247c to your computer and use it in GitHub Desktop.
Docker commands

Docker Commands

  • Run Docker Image: docker run -it your-image-name
  • Or, if you want to run a specific command within the image, like running a bash shell: docker run -it your-image-name /bin/bash
  • Create Docker Image: docker build -t your-project-name . The dot at the end indicates that the build should occur in the root directory. If you want to build from a different directory, use the ../ syntax.
  • List Docker Images: docker images
  • Remove Docker Image: docker image rm image-name
  • Forcefully Remove Docker Image: docker image rm image-name -f
  • List Containers: docker ps -a
  • Remove Container: docker container rm container_name
  • Forcefully Remove Container: docker container rm container_name -f
  • Remove all container and images docker system prune -a
  • Image create with versioning docker build -t basic-app:v1 .
  • Run container with image docker run --name container-name -p 5000:5000 basic-app:v1
  • Docker volumne docker run --name container-name -p 5000:5000 --rm -v your_project_path:/workdirectory basic-app
    • Example: docker run --name container-name -p 5000:5000 --rm -v D:\projects\learning\docker\dockerproj:/app basic-app
  • compose file run command docker compose up
  • push the image docker push neerajtangariya/basic-node-app
  • pull the public image docker pull neerajtangariya/basic-node-app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment