- I have a Dockerfile
Dockerfile.foo - I run
Dockerfile.foousingdocker run -p 8000:8000 --cap-add=IPC_LOCK johndoe/repo:latest
Everything works fine so far.
My issue is, --cap-add=IPC_LOCK is required to run Dockerfile.foo (no way around that, that I'm aware of).
However, I'd like to run Dockerfile.foo as a part of my dockercompose.yaml, because I have a few other services that use the container produced by Dockerfile.foo. Issue is, I can't figure out how to (1) either use the johndoe/repo:latest image, or (2) Use Dockerfile.foo in dockercompose.yaml and pass that --cap-add=IPC_LOCK flag to either the image or the Dockerfile (depending on whichever I'm allowed to use).
Is what I'm trying to do even possible? If not, is there a suggested/recommended way to attain my objective?
CodePudding user response:
You can use the cap_add clause in your docker compose file:
cap_add:
- IPC_LOCK
So your dockercompose.yaml would look something like:
version: "3.9"
services:
johndoe:
build: /path/to/dir
cap_add:
- IPC_LOCK
When you run docker compose up, the johndoe service will use an image built from the Dockerfile and run the container with the the --cap-add flag.
Also note that Dockerfile has no extension.
