Docker commands

Images

Format for image name:

<docker-id>/<project-repo>:<tag> (default tag: 'lastest') 

Create image:

docker build -t <image> .

Pull/push images from repository:

docker pull <image>
docker push <image>

Import/export images:

docker load -i <path to image>
docker save -o <path to tarfile> <image>

List and inspect images

docker inspect <image>
docker image list

Containers

Docker run creates a new container from a image and executes it.

docker run <options> <image> --name <container name>  
options:
 --rm removes container after finish
 -d detach/daemon
 -it interactive + terminal 

mappings:
 -p <host port>:<container port>
 -v <host folder>:<container folder>

Create, start and stop:

docker create <image> --name <container name>

docker start/stop <options> <container id/name>
options:
 -a appends output/stderr

Check logs, send SIGTERM and SIGKILL

docker logs <container>
docker stop <container>
docker kill <container>

Execute commands on running container

docker exec <-it> <container> <command>

Commit container to image

docker commit <options> <container> <image>
options:
 -c execute docker file command on image