Docker
Docker hub
Searching an Image
docker search <img-name>
Pull a Image
docker pull <image>:<version>
Run a Container
docker run -it <img-name> /bin/bash
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
List Images
docker images
List all Containers
docker ps -a
List Volumes
docker volume ls
Commit a Image
docker commit <container-id> <name>
Save image to a tar.gz file
docker save --output name.tar <container-name>
Import image from a tar.gz file
docker load < name.tar
Start containers automatically
systemctl enable docker
docker run -dit --restart unless-stopped <container-name>
Renaming a Container
docker rename <old-name> <new-name>
Delete a Container
docker rm <container-id>
Delete a Image
docker rmi <image-id>
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)