Downloading docker
Downloading container:
$ sudo docker pull ubuntu
$ sudo docker pull ubuntu:14.04
14.04 is a tag from docker image repository, it can be found here.
Deleting docker container
$ sudo docker rmi [NAME/IMAGE ID]
$ sudo docker rmi ubuntu:14.04
$ sudo docker rmi 00fd29ccc6f1
Listing
Info about docker:
sudo docker info
List all images:
$ sudo docker images
List running and stopped containers, -a for all
$ sudo docker ps
Searching
$ sudo docker search alpine --filter 'is-official=true'
$ sudo docker images --format '{{.Size}} {{.Repository}}'
Running
Run docker container:
$ sudo docker run hello-world
Attaching to process:
$ sudo docker attachach [container-id]
Run and attach to it:
$ sudo docker run -it ubuntu /bin/bash
Run docker container:
$ sudo docker run hello-world
Attaching to process:
$ sudo docker attachach [container-id]
Run and attach to it:
$ sudo docker run -it ubuntu /bin/bash
Ctrl + P + Q - Detaching from container
Running and binding port:
$ sudo docker run -p 90:90 -t [hash]
$ sudo docker restart 7d5bc3d73c1b
Running and binding port:
$ sudo docker run -p 90:90 -t [hash]
Running command:
$ docker run -it alpine:latest sleep 10
Reataching to container
$ docker ps
$ docker exec -it e37f24dc7e0a bash
$ docker ps
$ docker exec -it e37f24dc7e0a bash
Restarting
$ sudo docker restart 7d5bc3d73c1b
# After changing compose file run
$ sudo docker-compose up -d
$ sudo docker stop 7d5bc3d73c1b # sends SIGTERM to PID1
$ sudo docker kill 7d5bc3d73c1b # sends SIGKILL to PID1
Visi konteineriai saugomi:
# ls /var/lib/docker/containers/
Deleting Images
You cannot delete an image that is associated with a container in the running (Up) or stopped (Exited) states.
$ sudo docker images -q
$ sudo docker rmi 9f163cb3061e
Visi konteineriai saugomi:
# ls /var/lib/docker/containers/
$ sudo docker images -q
$ sudo docker rmi 9f163cb3061e
$ sudo docker rmi 9f163cb3061e
Deleting Images
You cannot delete an image that is associated with a container in the running (Up) or stopped (Exited) states.
$ sudo docker images -q
$ sudo docker rmi 9f163cb3061e
Post Installation steps
$ groups #Add user to docker group so we don't need sudo
$ sudo usermod -aG docker $user
$ newgrp dockerUseful command lines:
# Deleting all unused containers
$ docker container rm $(docker container ls -a -q)
# Deleting all unused images
$ docker image rm $(docker images -q)
$ docker container rm $(docker container ls -a -q)
# Deleting all unused images
$ docker image rm $(docker images -q)
Monitoring tools:
Resources: