Skip to main content

Docker

Docker hub

https://hub.docker.com/

Searching anĀ Image

docker search <img-name>

Renaming a Container

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

Pull a Image

docker pull <image>:<version>

List Images

docker images

Run a Container

docker run -it <img-name> /bin/bash

List all Containers

docker ps -a

Commit a Image

docker commit <container-id> <name>

Delete a Container

docker rm <container-id>

Delete a Image

docker rmi <image-id>

Run a Container with ports + volume

-v = volume, -p = port, -d = detach

docker run --name <name> -d -p 80:80 -v /data/websites:/var/www

Run a command inside container

docker exec -it <container-name> bash

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 --output name.tar <container-name>

Import image tofrom a tar.gz file

docker load < name.tar

Start containers automatically

systemctl enable docker
docker run -dit --restart unless-stopped <container-name>