当前位置:   article > 正文

Docker commands on Linux (WSL)

Docker commands on Linux (WSL)

Docker commands:

1.Docker service

  1. # start docker service by root
  2. sudo service docker start
  3. # stop docker service by root
  4. sudo service docker stop
  5. # show docker status
  6. service docker status

2.Docker image

  1. # Show docker image
  2. docker images
  3. # Delete docker image
  4. docker rmi {image ID or Name}
  5. # Docker image backup:
  6. # 列出现有镜像
  7. docker images
  8. # 选择要备份的镜像,并保存为 tar 文件
  9. docker save -o my_image_backup.tar my_image:latest
  10. 例如:docker save -o compreface_image_backup.tar exadel/compreface-core:1.2.0 exadel/compreface-fe:1.2.0 exadel/compreface-admin:1.2.0 exadel/compreface-api:1.2.0 exadel/compreface-postgres-db:1.2.0
  11. # 验证 tar 文件
  12. ls -lh my_image_backup.tar
  13. 例如:ls -lh compreface_image_backup.tar

2.Docker container 

  1. # Show docker container
  2. docker ps -a
  3. # Delete docker container
  4. docker rm {container ID or Name}
  5. # show docker log
  6. docker logs {container ID or Name}
  7. # Go to container
  8. docker exec -it {container ID or Name} /bin/bash
  9. docker exec -it {container ID or Name} /bin/sh
  10. # Start a contrainer
  11. docker run -it \
  12. -v /mnt/d/Tools/DevOps/wsl/gitlab-runner/config:/etc/gitlab-runner \
  13. -v /var/run/docker.sock:/var/run/docker.sock \
  14. --rm --name gitlab-runner gitlab/gitlab-runner:latest
  15. # Doesn't save a container
  16. docker run -it --rm --name {container name} -p {expose port:APP port} {docker image REPOSITORY:TAG}
  17. # Save a container
  18. docker run --name {container name} -p {expose port:APP port} {docker image REPOSITORY:TAG}

Linux commands: 

  1. # Go to Ubuntu from Windows
  2. \\wsl$\Ubuntu-18.04
  3. # Create a file
  4. touch {file name}
  5. # Delete a file
  6. rm {file name}
  7. # Create a folder
  8. mkdir {directory name}
  9. # Delete a folder
  10. rm -rf {directory name}
  11. # Copy directory
  12. cp -r {from} {to}
  13. # show file contents
  14. cat {file path}
  15. 例如:cat /etc/nginx/conf.d/nginx.conf
  16. # 查看物理 cpu 数:
  17. cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l
  18. # 查看每个物理 cpu 中 核心数(core 数):
  19. cat /proc/cpuinfo | grep "cpu cores" | uniq
  20. # 查看总的逻辑 cpu 数(processor 数):
  21. cat /proc/cpuinfo| grep "processor"| wc -l
  22. # 查看 cpu 型号:
  23. cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
  24. # lscpu 命令可以同时看到上述信息。
  25. lscpu
  26. # 查看IP和PORT是否畅通?
  27. echo > /dev/tcp/{IP}/{PORT} && echo "Port is open"
  28. 例如:echo > /dev/tcp/222.178.221.130/20001 && echo "Port is open"

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号