Running postgres docker container as a custom user

#create a system user, any uid shud be fine, I chose 2000
sudo useradd -u 2000 -r postgres
# create a directory on the host for bind mount
mkdir -p ~/volumes/postgres
# change ownership to postgres user
sudo chown $(id -u postgres):$(id -g postgres) ~/volumes/postgres
sudo chmod 700 -R ~/volumes/postgres
docker run — user “$(id -u postgres):$(id -g postgres)” -v ~/volumes/postgres:/var/lib/postgresql/data -d postgres:12.2




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium


Snowpipe Troubleshooting: Multiple Approaches

Testing in Apache Beam Part 2: Stream

Highly Paid DoorDash Engineers Have to Deliver Food, and They’re Not Having It

Practical API Protection Walkthrough — Part 3

Record your internet speeds using Python

An Outline for Using Hypothesis for Owning your Annotations and Highlights

Want to Actually Improve? Stop Obsessing Over Code Tutorials

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


More from Medium

Build your first CI/CD pipeline using Docker, Github Actions, and Webhooks while creating your own…

How to create APIs in API Connect

Launching architecture using Docker Compose

How to share docker images without Docker hub or any registry