The docker
command is a powerful tool used to manage containerized applications. It allows users to create, deploy, and run applications in containers, which are lightweight, portable, and self-sufficient environments that include everything needed to run a piece of software.
The basic syntax of the docker
command is as follows:
docker [options] [arguments]
Here are some common options you can use with the docker
command:
run
: Create and start a container.ps
: List running containers.images
: List available images on the local machine.pull
: Download an image from a Docker registry.build
: Build an image from a Dockerfile.exec
: Run a command in a running container.stop
: Stop a running container.docker run -d -p 80:80 nginx
docker ps
docker pull ubuntu
docker build -t my-image .
docker exec -it <container_id> bash
docker stop <container_id>
-d
option with run
to run containers in detached mode for background execution.docker-compose
for managing multi-container applications more easily.docker system prune
to free up space.