Friday, July 10, 2020

Useful Docker Commands

Below are some docker commands with examples.

  • docker run – Runs a command in a new container.
  • docker start – Starts one or more stopped containers
  • docker stop – Stops one or more running containers
  • docker build – Builds an image form a Docker file
  • docker pull – Pulls an image or a repository from a registry
  • docker push – Pushes an image or a repository to a registry
  • docker export – Exports a container’s filesystem as a tar archive
  • docker exec – Runs a command in a run-time container
  • docker search – Searches the Docker Hub for images
  • docker attach – Attaches to a running container
  • docker commit – Creates a new image from a container’s changes
  • docker rm - Remove container
  • docker images - List images
  • docker rmi imageid  -Remove Image
RUN Command Examples:
  • docker run --rm [IMAGE] – removes a container after it exits.
  • docker run -td [IMAGE] – starts a container and keeps it running.
  • docker run -it [IMAGE] – starts a container, allocates a pseudo-TTY connected to the container’s stdin, and creates an interactive bash shell in the container.
  • docker run -it-rm [IMAGE] – creates, starts, and runs a command inside the container. Once it executes the command, the container is removed.

No comments:

Post a Comment