Skip to content

Conversation

@skrech
Copy link
Contributor

@skrech skrech commented Jan 27, 2026

Description

Adds :z option to all the mounts in the docker-compose.yaml file. This should be a no-op for non-SElinux systems.

Request for comment: what do you think should happen for node_exporter? It's bind-mounting some OS-level dirs that, IMO, shouldn't (probably can't even) be re-labeled.

Tests

Local smoke test of running Trento Web on my SElinux-enabled Leap 16.

Copy link
Member

@balanza balanza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I leave the final decision to you. My opinions are:

  • disable SELinux labelling for node_exporter
  • afaik :z is not required for named volumes as they are managed by the container manager itself

- ./container_fixtures/keycloak/realm.json:/opt/keycloak/data/import/realm.json:ro,z
node_exporter:
image: docker.io/prom/node-exporter:v1.7.0
volumes:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should disable SELinux labeling for this service (I only found Podman docs about it https://docs.podman.io/en/v4.6.0/markdown/options/security-opt.html)

Suggested change
volumes:
security_opt:
- label:disable
volumes:

- prometheus_data:/prometheus
- ./prometheus-dev-config.yml:/etc/prometheus/prometheus.yml:z
- ./container_fixtures/prometheus:/container_init:z
- prometheus_data:/prometheus:z
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaik this is not needed for named volumes

Suggested change
- prometheus_data:/prometheus:z
- prometheus_data:/prometheus

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what keeps me from merging this, I want to test if :z is actually needed for named volumes.

- pg_data:/var/lib/postgresql/data
- ./container_fixtures/keycloak/init_keycloak_db.sh:/docker-entrypoint-initdb.d/init_keycloak_db.sh
- ./container_fixtures/postgres/init_wanda_db.sh:/docker-entrypoint-initdb.d/init_wanda_db.sh:ro
- pg_data:/var/lib/postgresql/data:z
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

named volume

Suggested change
- pg_data:/var/lib/postgresql/data:z
- pg_data:/var/lib/postgresql/data

image: ghcr.io/axllent/mailpit:v1.24
volumes:
- mailpit:/data
- mailpit:/data:z
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

named volumes

Suggested change
- mailpit:/data:z
- mailpit:/data

Copy link
Member

@nelsonkopliku nelsonkopliku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be working also in my macos 👀

Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having the next warning message:

WARN[0000] mount of type `volume` should not define `bind` option 
WARN[0000] mount of type `volume` should not define `bind` option 
WARN[0000] mount of type `volume` should not define `bind` option

I'm not sure if this is fixable. Just writing it here to see if anyone else having the same thing

@nelsonkopliku
Copy link
Member

I'm having the next warning message:

WARN[0000] mount of type `volume` should not define `bind` option 
WARN[0000] mount of type `volume` should not define `bind` option 
WARN[0000] mount of type `volume` should not define `bind` option

I'm not sure if this is fixable. Just writing it here to see if anyone else having the same thing

Actually I have the same @arbulu89

Copy link
Contributor

@gagandeepb gagandeepb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine in my development env. It is a no-op for me.

@skrech skrech force-pushed the docker-comp-selinux branch from eb763da to b8c68d7 Compare February 12, 2026 09:58
@skrech
Copy link
Contributor Author

skrech commented Feb 12, 2026

@balanza seems to be right, :z specifiers should be needed only when bind-mounting. I've removed it from named values. This should also clear your warnings in my opinion. Could some of you re-check? If the warning is gone, I'll merge this.

@skrech skrech requested a review from arbulu89 February 12, 2026 09:59
@arbulu89
Copy link
Contributor

@balanza seems to be right, :z specifiers should be needed only when bind-mounting. I've removed it from named values. This should also clear your warnings in my opinion. Could some of you re-check? If the warning is gone, I'll merge this.

Let me re-test this!

Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!
Warnings are gone and it works as before!
Thank you @skrech

@skrech
Copy link
Contributor Author

skrech commented Feb 12, 2026

Leaving node-exporter for now like this, maybe in the future we might try what @balanza suggested, if there are any problems.

    security_opt:
      - label:disable

Merging...

@skrech skrech merged commit 6a08c0d into main Feb 12, 2026
45 checks passed
@skrech skrech deleted the docker-comp-selinux branch February 12, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

5 participants