Translate

Some commands for docker

install docker:

curl -fsSL https://test.docker.com -o test-docker.sh sudo sh test-docker.sh

  1. list the containers: docker ps
  2. list all the containers: docker ps -a
  3. list the images: docker images
  4. change another image name: docker tag name1 name2
  5. commit the change to image: docker commit id name
  6. delete the image: docker rmi name
  7. stop a container: docker stop name
  8. remove a container: docker rm name
  • enter into a container: 
docker exec -it Name /bin/bash
  • save a image:
docker save image_name > Name.tar
  • load a image:
docker load < Name.tar
  • start a docker:
docker run --shm-size=1g --ulimit memlock=-1 --ulimit stack=67108864 --cap-add SYS_PTRACE --rm --gpus all --pid=host --net=host --security-opt apparmor:unconfined -e DISPLAY=$DISPLAY -v /home/temp:/workspace -v /home/pipeline:/data/pipeline -w /data/pipeline_capture -it Name


9. docker compose:
    start all the images:
        docker-compose up -d
        docker-compose up -d --build
        docker-compose -f docker-compose-local.yml -d --build
        (use a specific docker compose file)

    stop all the images:
        docker compose down


10. docker storage analysis:
    docker system df

11. docker clear storage:
    clean all:
        docker system prune
    clean cache:
        docker builder prune
    clean volume:
        docker volume prune
    clean container:
        docker container prune

12. docker logs:
    if i only want to check the last 100 lines of logs since a certain time:
        docker logs -f -t [--since="2018-02-08"] --tail=100 CONTAINER_ID
            -f: 跟踪实时日志
            -t: 显示时间戳
 
    if i only want to check the latest 30min of logs:
        docker logs --since 30m CONTAINER_ID





No comments:

Post a Comment