container

command module
v0.0.0-...-fcacf22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2021 License: MIT Imports: 5 Imported by: 0

README

container

Usage

启动容器:

./container run -it busybox /bin/sh

# 添加环境变量
./container run -it -e testhome=/opt/test busybox /bin/sh

# 挂载 volume
./container run -it -v /root/testvolume=/testvolume busybox /bin/sh

# 限制资源
./container run -it -m 100m --cpus 1 busybox /bin/sh

# expose port
./container run -it -m 100m --cpus 1 -p 8080:80 busybox /bin/sh

# 后台运行
./container run -d -m 100m --cpus 1 -p 8080:80 busybox /bin/sh

进入容器:

./container exec -it <container id> /bin/bash 

停止容器:

./container stop <container id>

删除容器:

./container rm <container id>

查看容器列表:

./container ps

提交容器:

./container commit <container id> <image name>

创建网络:

./container network create --driver bridge --subnet 192.168.99.0/24 testbridge

查看网络列表:

./container network ls

删除网络:

./container network rm testbridge

Release

Know issues

  • logs command error
  • cannot get $PATH
  • container status sync error (stop, rm -f cmd)
  • exit throw error
      2021-08-31T12:16:39.147+0800    ERROR   parent wait     {"error": "exit status 130"}
      2021-08-31T12:16:39.151+0800    WARN    remove cgroup fail unlinkat /sys/fs/cgroup/cpuset/q.container.cgroup/cpuset.memory_spread_slab: operation not permitted
      2021-08-31T12:16:39.152+0800    WARN    remove cgroup fail unlinkat /sys/fs/cgroup/memory/q.container.cgroup/memory.kmem.tcp.max_usage_in_bytes: operation not permitted
      2021-08-31T12:16:39.152+0800    WARN    remove cgroup fail unlinkat /sys/fs/cgroup/cpu,cpuacct/q.container.cgroup/cpu.rt_period_us: operation not permitted
      2021-08-31T12:16:39.152+0800    ERROR   container.Execute(): exit status 130
    
    
      2021-08-31T12:19:29.694+0800    ERROR   parent wait     {"error": "exit status 130"}
      2021-08-31T12:19:29.703+0800    ERROR   container.Execute(): exit status 130
    

TODO

  • 结构重构(容器信息,image,network, log 等)
  • image storage driver
  • 容器退出或者强制删除后,清除相关资源(workspace,mount point,iptables rules,container info,etc.)
  • 创建 iptables chain,iptables rules 添加包含 containerid 的注释
  • 构建 hook 函数,用来准备容器运行资源(创建目录)
  • recover panic
  • log pipe cannot close
  • 进程间 error 的传递
  • 删除创建文件之前 check 文件是否存在
  • 所有容器资源目录重命名
  • 文档,重要模块的实现原理
    • namespace 隔离
    • cgroups
    • aufs/overlay
    • -e 参数
    • --volume 参数
    • logs 命令,
    • exec 命令
    • exec -e 参数
    • network
    • port mapping

参考

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL