Docker commands
Thu Apr 18 2024 19:38:43 GMT+0000 (Coordinated Universal Time)
Saved by
@radeon323
#docker
#mongodb
#postgres
//show images
docker images
//show volumes
docker volume ls
//check if the volume is attached to any container:
docker ps -a --filter volume=<volume_name>
// remove volume
docker volume rm <volume_name>
//automatically delete unused volumes
docker volume prune
//upack mongo.tar with volume to the directory
tar -xvf mongo.tar -C /path/to/mongo-data
//run docker container from image with attached volume
//mongodb_dm - volume name
//mongo - container name
docker run -d --name mongo -v mongodb_dm:/data/db -p 27017:27017 mongo:latest
docker run -d --name mongo -v mongodb_dm:/data/db -p 27017:27017 mongo:4.4
// with attached volume
docker run -d --name mongo -v /path/to/mongo-data:/data/db -p 27017:27017 mongo:4.4
docker run -d --name mongo -v mongo:/data/db -p 27017:27017 mongo:4.4
// run shel inside the container
docker exec -it mongo mongo
// with attached volume and auth
docker run -d --name mongo -v /path/to/mongo-data:/data/db -p 27017:27017 mongo:4.4 --auth
docker exec -it mongo mongo -u "admin" -p "yourpassword" --authenticationDatabase "admin"
docker inspect <container_id>
//enter into container
docker exec -it <container ID> bash
//build daemon
docker-compose up --build -d
docker stop <container ID>
docker rm <container ID>
//postgres with attached volume(directory)
docker run -d --name postgres -e POSTGRES_USER=<user> -e POSTGRES_PASSWORD=<password> -p 5432:5432 -v /path/to/postgres:/var/lib/postgresql/data postgres:14
content_copyCOPY
Comments