Saturday, August 26, 2023

DOCKER

REFERENCES:

https://www.freecodecamp.org/news/where-are-docker-images-stored-docker-container-paths-explained/

 

1)  The output contains information about your storage driver and your docker root directory

$ docker info 
 
2) A Docker container consists of network settings, volumes, and images.
 
 Ubuntu: /var/lib/docker/
 
3) Docker images
  Docker images are stored in /var/lib/docker/overlay2
 
4) Docker Volumes
 
$ docker run --name nginx_container -v /var/log nginx 
 
5)Clean up space used by Docker
$ docker system prune -a 
 
6) To get container size and container info
$ docker ps -s
$ docker ps -a 
 
7) pull down an image from a repository, 
docker pull 
create a container from an image that does not yet exist locally, each layer is
pulled down separately, and stored in Docker's local storage area, which is
usually /var/lib/docker/ 
 
8) Check out the sizes of the images:
docker image ls
9) create a volume
docker volume create my-vol 
10) List Volumes
docker volume ls

11) Inspect volume
docker volume inspect my-vol
 12) To backup volume
 docker run --volumes-from --container_name-- -v $(pwd):--path-- ubuntu tar cvf --path--/storage.tar /app/storage/app/public
13) To restore volume
docker run --rm --volumes-from --container_name-- -v $(pwd):--path-- bash -c "cd storage/app/public && tar xvf --path--/storage.tar" 
14) To restore volume 
docker exec -it docker-webserver-1 /bin/bash 
 
TTo Set up ssl certificate:

docker compose run --rm certbot certonly --manual --preferred-challenges dns -d example.com -d *.example.com -v
 
docker ps
docker restart docker-name
docker system df
 df -h
docker builder prune
docker exec -it docker-webserver-1 /bin/sh
docker logs docker-webserver-1
Dangling images are images that are not associated with any running containers and are not tagged with a specific version or name. These images are typically left behind when you build or pull new images, and older, unused versions are no longer needed. They can accumulate over time and consume disk space. 
docker image prune
docker container prune 

No comments:

Post a Comment