Nutshell

Pull Image

docker pull debian

Create container from image

docker run debian # The container will get a random name.
docker run debian --name "my-debian" # recommended

Start a container and mount Apache document root to a local folder in your workstation:

docker run --name "my-debian" -it --mount type=bind,source=/work/my-projects,target=/var/www/html debian

Start/Stop container

docker start my-debian
docker stop my-debian

Connect container

docker exec -it my-debian /bin/bash

List running containers

docker ps

List all containers

List images

Delete container

Delete image

Save container as an image

Load an image from backup

Push image

Build an image

You can create custom images using docker build. For example, you can start from a base image (eg Debian) and the install custom software according to your needs (php, Apache, MySQL or whatever).

Transfer files

From local file system to running container:

From running container to local file system:

Docker info

Docker inspect

Use docker inspect to get information for a specific docker object (eg image, container, network, etc)

Last updated