Skip to main content

Docker

Searching anĀ Image

docker search <img-name>

Renaming a Container

docker rename <old-name> <new-name>
Docker hub

https://hub.docker.com/

Pull a Image

docker pull linux:<image>:<version>

List Images

docker images

Run a Container

docker run -it (run and interact) imagename<img-name> /bin/bash

commit

List aall image

Containers

docker ps -a

Commit a Image

docker commit $ID<container-id> $NAME<name>

Delete a Container

docker rm $ID<container-id>

Delete a Image

docker rmi $ID<image-id>

Run a Container with ports + volume

docker run --name my_name -d -p 80:80 -v /data/websites:/var/www
(-v = volume, -p = port, -d = detach)

Stop+Delete all Containers+Images

docker stop $(docker ps -a -q)
docker rm $(docker ps -a -f status=exited -q)
docker rm $(docker ps -a -q)
docker rmi $(docker images -q)

List Volumes

docker volume ls

Save image to a tar.gz file

docker save -o-output name.tar <savecontainer-name>

Import image to path>a tar.gz file

docker import container.tar <image container-name>
docker load -i <path to image tar file>

.

Start containers automatically
systemctl enable docker
docker run -dit --restart unless-stopped nginx

docker exec -it nginx bash

docker top nginx