0

How to build postgis container as root user using docker-compose up?

In Dockerfile, separate attempts to set USER to root as well 0 did not work.

Updating docker-compose service with user: '0' was tried to no avail.

There error I am getting is Permission denied.

The id -u is always running as 999 during the build. This seems to be a system user with limited privilege.

I would prefer to just run docker-compose up with no flags and keep all configurations in docker-compose.yml and/or Dockerfile.

Dockerfile

FROM postgis/postgis:13-3.3
USER root
COPY ./startup.sh /docker-entrypoint-initdb.d/startup.sh

NOTE:

I realized that I should have added more context. I created another post that better describes the issue.

Open SSH tunnel during PostGIS Docker build

user2517182
  • 1,241
  • 3
  • 15
  • 37

1 Answers1

0

Please be carefull with root, it can inject vulnerabilities in your database. I highly recommend to you to use it only for development.

You can run this command below:

docker-compose up --user root

Or put it in your docker-compose file:

services:
  postgis:
    user: root
Julien Ambrosio
  • 311
  • 2
  • 6
  • Much appreciation for your answer. However this did not work for my use case. I realize I may not have given the all the proper context. I thought mentioning PostGIS was enough. I have created another post that give more context and code snippets. Would you take a look at that one https://stackoverflow.com/questions/74855870/open-ssh-tunnel-during-postgis-docker-build. Thanks! – user2517182 Dec 19 '22 at 20:57