Docker tutorial

https://jobs.hybrid-technologies.vn/blog/huong-dan-su-dung-docker-co-ban/



Doker tutorial
---------------------
docker info

chỉ ra docker đang có bao nhiêu ảnh, bao nhiêu containner đang chạy hay dừng

--------------------
dùng lệnh 
docker images : để xem danh sách các ảnh đã tải về


------ Làm thế nào để có ảnh
docker pull  : dùng để donwload image từ dockerhub
docker pull <image_name:tag>

-------sau khi có ảnh rồi thì cài đặt như nào
1. docker run {image_name or id_image}
2. docker run {image_name}:{tag_name} trường hợp bạn có nhiều version ảnh của một phần mềm (ví dụ redis:1.1, redis latest, redis :1.2)

3. docker run -d --name  container-name -p localhost:80:80 -v $HOME/myContainer/configDir:/myImage/configDir --restart=always image-name
4. ex: sudo docker run -d -p 6379:6379 --name redis1 redis
--detach , -d       Run container in background and print container ID
--name              Assign a name to the container
--publish , -p      Publish a container’s port(s) to the host
--volume , -v       Bind mount a volume
--restart           Restart policy to apply when a container exits

------ Để xem các ảnh đang running
docker ps : để xem danh sách các running images
docker ps -a #Liệt kê các container đã tắt


------Để stop 1 container đang chạy
docker stop container_id

-----để start 1 containner đã dừng
sudo docker start -ai {container_id}
sudo docker start  {container_id}

---- truy cập vào container
docker exec -it <id | name> bash

-- check log của container
docker logs <id | name> bash


-------Xóa một container
docker rm -f {container_id/name}
docker rm {container_id}


---------Cuối cùng là xóa 1 ảnh đã tải về
 sudo docker rmi {image_name}

------- Xem thông tin một container
docker inspect {name or id}

------
List all containers (only IDs)
docker ps -aq
Stop all running containers
docker stop $(docker ps -aq)
Remove all containers
docker rm $(docker ps -aq)
Remove all images
docker rmi $(docker images -q)

Comments

Popular posts from this blog

Fixing the DeepSpeed Import Error While Fine-Tuning the Qwen Model

Amazon Linux 2023 - User data configuration for launch templates to connect to the EKS cluster

How to create ISM policy and rotate logs in opensearch