Docker Commands
- Docker Commands
- Basic Commands
- Advanced Commands
- docker run -d
- docker run -it
- docker run -p
- docker run -v
- docker run –name
- docker run –rm
- docker run –network
- docker run –env
- docker run –link
- docker run –restart
- docker run –privileged
- docker run –user
- docker run –cpus
- docker run –memory
- docker run –memory-swap
- docker run –memory-swappiness
- docker run –cpu-shares
- docker run –cpu-period
- docker run –cpu-quota
- docker run –cpuset-cpus
- docker run –cpuset-mems
On this page
- Docker Commands
- Basic Commands
- Advanced Commands
- docker run -d
- docker run -it
- docker run -p
- docker run -v
- docker run –name
- docker run –rm
- docker run –network
- docker run –env
- docker run –link
- docker run –restart
- docker run –privileged
- docker run –user
- docker run –cpus
- docker run –memory
- docker run –memory-swap
- docker run –memory-swappiness
- docker run –cpu-shares
- docker run –cpu-period
- docker run –cpu-quota
- docker run –cpuset-cpus
- docker run –cpuset-mems
Docker Commands
Basic Commands
docker run
The docker run
command is used to run a container from an image. The command will pull the image from the registry if it is not already present on the host.
docker run <image>
docker ps
The docker ps
command is used to list the running containers on the host.
docker ps
docker ps -a
The docker ps -a
command is used to list all containers on the host.
docker ps -a
docker images
The docker images
command is used to list all images on the host.
docker images
docker pull
The docker pull
command is used to pull an image from the registry.
docker pull <image>
docker stop
The docker stop
command is used to stop a running container.
docker stop <container>
docker rm
The docker rm
command is used to remove a container.
docker rm <container>
docker rmi
The docker rmi
command is used to remove an image.
docker rmi <image>
docker exec
The docker exec
command is used to execute a command in a running container.
docker exec <container> <command>
docker logs
The docker logs
command is used to view the logs of a container.
docker logs <container>
docker inspect
The docker inspect
command is used to view the details of a container.
docker inspect <container>
docker build
The docker build
command is used to build an image from a Dockerfile.
docker build -t <image> .
docker push
The docker push
command is used to push an image to the registry.
docker push <image>
docker tag
The docker tag
command is used to tag an image.
docker tag <image> <tag>
docker login
The docker login
command is used to login to the registry.
docker login
docker logout
The docker logout
command is used to logout of the registry.
docker logout
docker network
The docker network
command is used to manage Docker networks.
docker network ls
docker volume
The docker volume
command is used to manage Docker volumes.
docker volume ls
docker system
The docker system
command is used to manage Docker system.
docker system df
docker stats
The docker stats
command is used to view the resource usage of containers.
docker stats
docker top
The docker top
command is used to view the processes running in a container.
docker top <container>
docker port
The docker port
command is used to view the port mappings of a container.
docker port <container>
docker version
The docker version
command is used to view the Docker version.
docker version
docker info
The docker info
command is used to view the Docker system information.
docker info
Advanced Commands
docker run -d
The docker run -d
command is used to run a container in detached mode.
docker run -d <image>
docker run -it
The docker run -it
command is used to run a container in interactive mode.
docker run -it <image>
docker run -p
The docker run -p
command is used to publish a container’s port to the host.
docker run -p <host-port>:<container-port> <image>
docker run -v
The docker run -v
command is used to mount a volume to a container.
docker run -v <host-path>:<container-path> <image>
docker run –name
The docker run --name
command is used to name a container.
docker run --name <name> <image>
docker run –rm
The docker run --rm
command is used to remove a container after it exits.
docker run --rm <image>
docker run –network
The docker run --network
command is used to run a container in a network.
docker run --network <network> <image>
docker run –env
The docker run --env
command is used to set environment variables in a container.
docker run --env <key>=<value> <image>
docker run –link
The docker run --link
command is used to link a container to another container.
docker run --link <container> <image>
docker run –restart
The docker run --restart
command is used to restart a container on failure.
docker run --restart <policy> <image>
docker run –privileged
The docker run --privileged
command is used to run a container in privileged mode.
docker run --privileged <image>
docker run –user
The docker run --user
command is used to run a container as a specific user.
docker run --user <user> <image>
docker run –cpus
The docker run --cpus
command is used to limit the CPU usage of a container.
docker run --cpus <number> <image>
docker run –memory
The docker run --memory
command is used to limit the memory usage of a container.
docker run --memory <number> <image>
docker run –memory-swap
The docker run --memory-swap
command is used to limit the swap memory usage of a container.
docker run --memory-swap <number> <image>
docker run –memory-swappiness
The docker run --memory-swappiness
command is used to set the swappiness of a container.
docker run --memory-swappiness <number> <image>
docker run –cpu-shares
The docker run --cpu-shares
command is used to set the CPU shares of a container.
docker run --cpu-shares <number> <image>
docker run –cpu-period
The docker run --cpu-period
command is used to set the CPU period of a container.
docker run --cpu-period <number> <image>
docker run –cpu-quota
The docker run --cpu-quota
command is used to set the CPU quota of a container.
docker run --cpu-quota <number> <image>
docker run –cpuset-cpus
The docker run --cpuset-cpus
command is used to set the CPU cores of a container.
docker run --cpuset-cpus <number> <image>
docker run –cpuset-mems
The docker run --cpuset-mems
command is used to set the CPU memory nodes of a container.
docker run --cpuset-mems <number> <image>