Code Monkey home page Code Monkey logo

docker's Introduction

docker

通过docker批量或单独开设NAT服务器(Bulk or individual NAT server provisioning via docker)

默认使用debian系统,每个容器自带1个外网ssh端口,25个内外网一致端口

默认创建的是非特权容器,且不挂载与宿主机的docker的守护进程之间的通信,所以宿主机创建的docker虚拟化的NAT服务器内无法再嵌套虚拟化docker

由于只是在宿主机进行了CPU和内存的限制未在容器内使用cgroup驱动,所以在容器内使用服务器测试脚本检测容器的可用资源是无效的,显示的会是宿主机的资源

由于大部分云服务器xfs文件系统不启用pquota选项,所以默认共享宿主机硬盘,无法限制每个容器的磁盘大小

配置要求

系统可安装docker即可用,网络能连接Github的raw界面就能用,硬件配置只要不拉跨就行,空闲硬盘有3G就行

推荐在开设NAT服务器前先增加部分SWAP虚拟内存,避免突发的内存占用导致母鸡卡死 跳转

环境预设

  • 检测环境
  • 安装docker
  • 下载预制脚本
curl -L https://raw.githubusercontent.com/spiritLHLS/docker/main/scripts/pre_build.sh -o pre_build.sh && chmod +x pre_build.sh && bash pre_build.sh

单独开设

下载脚本

curl -L https://raw.githubusercontent.com/spiritLHLS/docker/main/scripts/onedocker.sh -o onedocker.sh && chmod +x onedocker.sh

运行

./onedocker.sh name cpu memory password sshport startport endport system

目前system仅支持选择alpine或debian,默认是debian

示例

将开设1核512MB内存,root的密码是123456,SSH端口映射至外网25000,批量映射的端口区间为34975到35000,此区间内外网端口一致,系统为debian

./onedocker.sh test 1 512 123456 25000 34975 35000 debian

删除示例

docker rm -f test
rm -rf test
ls

进入示例

docker exec -it test /bin/bash

查询信息

cat 容器名字

输出格式

容器名字 SSH端口 登陆的root密码 核数 内存 外网端口起 外网端口止 

批量开设

  • 批量多次运行继承配置生成
  • 生成多个时为避免SSH连接中断建议在screen中执行
curl -L https://raw.githubusercontent.com/spiritLHLS/docker/main/scripts/dockers.sh -o dockers.sh && chmod +x dockers.sh && bash dockers.sh

卸载所有docker容器和镜像

docker rm -f $(docker ps -aq); docker rmi $(docker images -aq)
rm -rf dclog
ls

docker's People

Contributors

spiritlhls avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.