Common Docker commands

The following common Docker commands may be helpful as you create containers and specify images.

Command Description
docker images Lists all the available Docker images.
docker --ps all Lists all the available Docker containers.

docker start|stop|restart <container>

Start, stop, or restart containers.

docker rm <container>

Removes the container.

Before removing a container, the container should be stopped.

docker rmi <image>

Removes the Docker image.

Before removing the image, all the associated containers should be removed.

docker exec –it<container> bash

Get into a running container.

docker cp <container>:<path> <host-path>

docker cp <host-path> <container>:<path>

Copy files to and from a container.

docker logs<container>

Retrieves generated console messages from the container.

Note: See the Docker documentation for a detailed discussion of these and additional commands.