Managing Docker Images | |
---|---|
Command | Description |
docker image ls | List docker images. You can also use the command docker images |
docker image inspect some_image | Dispaly detailed information about the specified image. |
docker image rm some_image | Remove one or more images. |
docker image history some_image | Show history of an image. |
docker image prune | Remove dangling images. |
docker rmi $(docker images -a -q) | Remove all Docker images. |
docker run some_image | Start a Docker container from the specified image. |
docker run some_image -d -it --name container_name | Start a Docker container from image. -d option is to run the container in detached mode. -it option is for interactive mode. --name option is used to specify a name to identify the container. |
docker build -t name:tag | Build an image from the Dockerfile. |
Note: some_image can be name, id or prefix of an image. | |
Managing Docker Containers | |
docker container ls | List running Docker containers. |
docker container ls -a | List all Docker container including containers that exited. |
docker container inspect some_container | Display detailed information of a specified container. |
docker container attach some_container | Attach standard input, output and error streams to a running container. To detach, press CTRL-p CTRL-q |
docker container commit -p some_container image_name:tag | Create a new image with the file changes from a running container. -p option is to pause the container during commit. |
docker container stop some_container | Stop a running container. |
docker container rm some_container | Remove a container. |
docker container cp source_path destination_path | Copy files and folders between local filesystem and a container. The container file path must be prefixed by the container name in the format container_name:/file/path |
docker container stats some_container | Display resource usage statistics of a running container. If container name is omitted, resource usage of all containers are displayed. |
docker container logs some_container | Display a container's logs. |
docker container restart some_container | Restart a container. |
docker container rename some_container new_container_name | Rename a container. |
docker container kill some_container | Kill one or more containers. |
docker container top | Display running processes in a container. |
docker container start some_container | Start a container that was stopped before. |
docker container exec some_container command | Run a command in a container that is running. The --it option can be used to run the command in interactive mode. |
Note: some_container can be name, id or prefix of a container. | |
Docker Network Commands | |
docker network ls | List available networks. |
docker network inspect network_name | Display detailed information about the specified network |
docker network connect network_name container_name | Connect a container to the specified network. You can use the --ip option to specify the ip address to be assigned to the container. |
docker network disconnect network_name container_name | Disconnect a container from a network. |
docker network create -d driver network_name | Create a network with the specified name. The drive can be bridge or overlay. Default is bridge if -d option is omitted. |
Docker Registry Commands | |
docker pull Image_name:tag | Pull a Docker image or repository from the Docker Hub registry. |
docker push Image_name:tag | Push an image or repository to Docker Hub registry |
docker login -u Username | Login to Docker Hub registry. |
docker logout | Logout from Docker Hub registry. |
General Docker Commands | |
docker --version | Display docker version. |
docker info | Show system wide information of the Docker installation. |
docker | List all Docker commands. |