我需要能够分叉一个过程.据我所知,我需要设置security-opt.我试过用docker命令做这个,它工作正常.但是,当我在docker-compose文件中执行此操作时,它似乎什么都不做,也许我没有使用compose right.
搬运工人
docker run --security-opt=seccomp:unconfined
泊坞窗,撰写
建立
泊坞窗,compose.yml
networks:
backend:
services:
example:
build: .
security_opt:
- seccomp:unconfined
networks:
- backend
ports:
- "5002:5002"
Dockerfile
FROM golang:1.8
RUN go get -u github.com/derekparker/delve/cmd/dlv
RUN dlv debug --listen=:2345 --headless --log ./cmd/main.go
命令
docker-compose -f docker-compose.yml up --build --abort-on-container-exit
结果
2017/09/04 15:58:33 server.go:73: Using API v1 2017/09/04 15:58:33
debugger.go:97: launching process with args: [/go/src/debug] could not
launch process: fork/exec /go/src/debug: operation not permitted
最佳答案
撰写语法是正确的.但是security_opt将应用于容器的新实例,因此在构建时不可用,就像您尝试使用Dockerfile RUN命令一样.
正确的方法应该是:
Dockerfile:
FROM golang:1.8
RUN go get -u github.com/derekparker/delve/cmd/dlv
泊坞窗,compose.yml
networks:
backend:
services:
example:
build: .
security_opt:
- seccomp:unconfined
networks:
- backend
ports:
- "5002:5002"
entrypoint: ['/usr/local/bin/dlv','--listen=: 2345','--headless=true','--api-version=2','exec','cmd/main.go']