This guide walks through setting up a basic policy that allows a group of users to run containers from approved images, with access to specific ports and volumes.
HBM is installed and running. Authorization is enabled:
hbm config set authorization trueAdd each user that will connect via Docker. The name must match the CN in their TLS client certificate:
hbm user add alice
hbm user add bobhbm group add developers
hbm user member developers alice --add
hbm user member developers bob --addResources are the individual permissions. Create one resource per permission:
# Allow basic Docker actions
hbm resource add allow-info -t action -v container_info
hbm resource add allow-ps -t action -v container_list
hbm resource add allow-run -t action -v container_create
hbm resource add allow-start -t action -v container_start
hbm resource add allow-stop -t action -v container_stop
hbm resource add allow-rm -t action -v container_remove
hbm resource add allow-logs -t action -v container_logs
hbm resource add allow-pull -t action -v image_create
hbm resource add allow-images -t action -v image_list
# Allow specific images
hbm resource add allow-nginx -t image -v nginx
hbm resource add allow-alpine -t image -v alpine
# Allow a volume path
hbm resource add allow-tmp -t volume -v /tmp
# Allow a port
hbm resource add allow-port-8080 -t port -v 8080A collection groups resources together:
hbm collection add basic-docker
hbm resource member basic-docker allow-info --add
hbm resource member basic-docker allow-ps --add
hbm resource member basic-docker allow-run --add
hbm resource member basic-docker allow-start --add
hbm resource member basic-docker allow-stop --add
hbm resource member basic-docker allow-rm --add
hbm resource member basic-docker allow-logs --add
hbm resource member basic-docker allow-pull --add
hbm resource member basic-docker allow-images --add
hbm resource member basic-docker allow-nginx --add
hbm resource member basic-docker allow-alpine --add
hbm resource member basic-docker allow-tmp --add
hbm resource member basic-docker allow-port-8080 --addA policy links a group to a collection:
hbm policy add dev-policy -g developers -c basic-dockerCheck what's configured:
hbm policy ls
hbm collection ls
hbm resource lsAlice and Bob can now:
- Pull and run
nginxandalpineimages - Mount
/tmp - Expose port
8080 - But not: run
--privileged, mount arbitrary paths, pull other images, or expose other ports
Without explicit resources, the following are always denied:
--privileged--net=host--pid=host- Mounting paths not in the volume whitelist
- Pulling images not in the image whitelist
- Exposing ports not in the port whitelist
- Adding Linux capabilities not in the capability whitelist