0

I am currently testing Azure Container Instances and want to deploy a multi-container project set up with docker compose. However, I already struggle setting up only a single postgres container with my custom config file as part of docker compose.

The Dockerfile looks as follows:

FROM postgres:14
RUN chown -R postgres:postgres /etc/postgresql/
COPY ./db-postgres/postgresql.conf /etc/postgresql/postgresql.conf
COPY ./db-postgres/init.sql /docker-entrypoint-initdb.d/init.sql

The docker compose YAML is:

version: "3.5"

services:
  postgres:
    container_name: postgres-acr
    image: <containerregistry>.azurecr.io/postgres:dev
    build:
      context: ./
      dockerfile: ./docker/Dockerfile_postgres
    command: postgres -c 'config_file=etc/postgresql/postgresql.conf'
    environment:
      POSTGRES_DB: <dbname>
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: <userpassword>
    user: postgres
    ports:
      - 5432:5432

On my local windows based machine this setup works fine with Docker Desktop and WSL2. However, if I deploy this container in Azure Container Instances, I continue to receive the following error:

"root" execution of the PostgreSQL server is not permitted. The server must be started under a nunprivileged user ID to prevent possible system security comprise.

According to several other posts on Stackoverflow (e.g. "root" execution of the PostgreSQL server is not permitted) this indicates that the command postgres -c 'config_file=etc/postgresql/postgresql.conf' is executed via root, but should instead be executed by the postgres user. I tried to make sure that it is executed by the postgres user, by setting the user property in the service definition, but the problem persists.

I am confused what I am missing and why the given setup works fine on my local machine, but fails in Azure Container Instances.

Hope someone can help. Thanks!

Jens
  • 35
  • 2

0 Answers0