Coder Social home page Coder Social logo

docker's Introduction

docker-by-hand

手写docker 开发过程中使用docker环境调试,命令如下:

# 构建docker镜像
docker build -t golang:lab

# 进入容器shell
docker run -it --rm --privileged --name golab -v /project/path:/go/src -w /go/src golang:lab /bin/bash

# 直接运行go run main.go
docker run -it --rm --privileged --name golab -v /project/path:/go/src -w /go/src golang:lab go run main.go

# 限制容器的内存
docker run -m 1G --memory-swap 1G -it --name golab --rm --privileged -v /project/path:/go/src -w /go/src golang:lab
go run main.go run -ti -m 100m stress --vm 1 --vm-bytes 200m --vm-keep

# cpu时间片分配比例
nohup stress --vm-bytes 200m --vm-keep --vm 1 &
go run main.go run -ti -cpushare 512 stress --vm-bytes 200m --vm-keep --vm 1

5.1 实现容器的后台运行 我当前开发的环境内核版本为4.4.0,当主进程退出后,容器进程的PPID不会变为1,而是变成init --user的PID,这是从systemd 219 开始引入的新特性,它被用来管理用户级别的 systemd 服务。

6.5 将网桥地址转换成宿主机出口网卡的IP

sysctl -w net.ipv4.conf.all.forwarding=1
iptables -t nat -A POSTROUTING -s 172.18.0.0/24 -o eth0 -j MASQUERADE

docker's People

Contributors

wss404 avatar

Watchers

 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.