Skip to content

Docker - running as non-root #75

Description

@karpana

Is there any advice-guidance on how to get the docker container to run as non-root? It seems that something with the way this docker container is assembled is forcibly trying to create folders in /, and as such requires root access, even when the folder(s) (I suspect it's the .config structure) are already in place)

I"ve created ephemeral bind mounts so that thet dbus and x11 capabilities to not error out, but this same approach is not working for this hard /root directory creation...

This is the last piece I'm struggling with, and can't be "gotten around", as the container seems to be doing things even before ephemeral bind mounts are active.

This is the error I'm getting

Starting Xvfb...

Xvfb started successfully (PID: 8)

Warning: dbus-daemon (session) failed to start

mkdir: cannot create directory '/root': Permission denied

and here's my currenct service definition (part of a larger service stack):

services:
  printventory:
    image: printventory/printventory:latest
    user: "7111:8000"
    environment:
      TZ: America/Winnipeg
    deploy:
      placement:
        constraints:
          - node.role == worker
      mode: replicated
      replicas: 1
    networks:
      - network
      - npm_proxy_network
    expose:
      - 5000
    volumes:
      # Persistent application data
      - /docker_shared_storage/printventory/config:/root/.config/printventory
      - /docker_shared_storage/printventory/models:/mnt/models
      # Ephemeral runtime files — created independently on whichever
      # Swarm worker receives the task.
      # Ephemeral runtime locations
      - type: tmpfs
        target: /root
        tmpfs:
          mode: 0777
      - type: tmpfs
        target: /run/dbus
        tmpfs:
          mode: 0777
      - type: tmpfs
        target: /tmp/.X11-unix
        tmpfs:
          mode: 01777 

networks:
  network:
    driver: overlay
  npm_proxy_network:
    external: true    

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions