Common Docker commands
The following table describes commonly used Docker commands. For a complete list of Docker commands click here.
Command | Description |
---|---|
docker login <repository domain> | Specify login credentials for a specific repository. |
docker pull image_name | Download a particular image (from specified repository sources). |
docker images | List all images present locally. |
docker rmi <image_name|image_id> | Remove the image. |
docker ps | List all running containers. |
docker ps -a | List all containers |
docker run [options] <image_name|image_id> | Run the docker image with specified options. |
docker stop <container_name|container_id> | Stop a running container. |
docker rm <container_name|container_id> | Remove a stopped container. |
docker logs | Look at logs for a running or stopped container. |
docker kill | Kill one or more running containers. |
docker cp <container:path_to_file> <dest_path> | Copy the file from inside the container to your local host machine. |
docker restart <container> | Restart the container. |
docker rename <container> <new name> | Rename the container. |
docker exec -it <container name> bash | Runs an interactive bash shell on a running container. |
Docker flags
The following table describes commonly used Docker flags.
Command | Description |
---|---|
docker run -t | Allocate a pseudo-tty. |
docker run -d | Run container in detached mode. |
docker run -p | Specify port mapping. |
docker run -v | Map a volume. |