Skip to content

Commit ee20f10

Browse files
committed
Add "mkdir ~postgres" with proper permissions
1 parent 3b9d57d commit ee20f10

File tree

6 files changed

+60
-12
lines changed

6 files changed

+60
-12
lines changed

9.2/alpine/Dockerfile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@
22
FROM alpine:3.5
33

44
# alpine includes "postgres" user/group in base install
5-
# /etc/passwd:22:postgres:x:70:70::/var/lib/postgresql:/bin/sh
6-
# /etc/group:34:postgres:x:70:
5+
# /etc/passwd:22:postgres:x:70:70::/var/lib/postgresql:/bin/sh
6+
# /etc/group:34:postgres:x:70:
7+
# the home directory for the postgres user, however, is not created by default
8+
# see https://github.com/docker-library/postgres/issues/274
9+
RUN set -ex; \
10+
postgresHome="$(getent passwd postgres)"; \
11+
postgresHome="$(echo "$postgresHome" | cut -d: -f6)"; \
12+
[ "$postgresHome" = '/var/lib/postgresql' ]; \
13+
mkdir -p "$postgresHome"; \
14+
chown -R postgres:postgres "$postgresHome"
715

816
# su-exec (gosu-compatible) is installed further down
917

9.3/alpine/Dockerfile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@
22
FROM alpine:3.5
33

44
# alpine includes "postgres" user/group in base install
5-
# /etc/passwd:22:postgres:x:70:70::/var/lib/postgresql:/bin/sh
6-
# /etc/group:34:postgres:x:70:
5+
# /etc/passwd:22:postgres:x:70:70::/var/lib/postgresql:/bin/sh
6+
# /etc/group:34:postgres:x:70:
7+
# the home directory for the postgres user, however, is not created by default
8+
# see https://github.com/docker-library/postgres/issues/274
9+
RUN set -ex; \
10+
postgresHome="$(getent passwd postgres)"; \
11+
postgresHome="$(echo "$postgresHome" | cut -d: -f6)"; \
12+
[ "$postgresHome" = '/var/lib/postgresql' ]; \
13+
mkdir -p "$postgresHome"; \
14+
chown -R postgres:postgres "$postgresHome"
715

816
# su-exec (gosu-compatible) is installed further down
917

9.4/alpine/Dockerfile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@
22
FROM alpine:3.5
33

44
# alpine includes "postgres" user/group in base install
5-
# /etc/passwd:22:postgres:x:70:70::/var/lib/postgresql:/bin/sh
6-
# /etc/group:34:postgres:x:70:
5+
# /etc/passwd:22:postgres:x:70:70::/var/lib/postgresql:/bin/sh
6+
# /etc/group:34:postgres:x:70:
7+
# the home directory for the postgres user, however, is not created by default
8+
# see https://github.com/docker-library/postgres/issues/274
9+
RUN set -ex; \
10+
postgresHome="$(getent passwd postgres)"; \
11+
postgresHome="$(echo "$postgresHome" | cut -d: -f6)"; \
12+
[ "$postgresHome" = '/var/lib/postgresql' ]; \
13+
mkdir -p "$postgresHome"; \
14+
chown -R postgres:postgres "$postgresHome"
715

816
# su-exec (gosu-compatible) is installed further down
917

9.5/alpine/Dockerfile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@
22
FROM alpine:3.5
33

44
# alpine includes "postgres" user/group in base install
5-
# /etc/passwd:22:postgres:x:70:70::/var/lib/postgresql:/bin/sh
6-
# /etc/group:34:postgres:x:70:
5+
# /etc/passwd:22:postgres:x:70:70::/var/lib/postgresql:/bin/sh
6+
# /etc/group:34:postgres:x:70:
7+
# the home directory for the postgres user, however, is not created by default
8+
# see https://github.com/docker-library/postgres/issues/274
9+
RUN set -ex; \
10+
postgresHome="$(getent passwd postgres)"; \
11+
postgresHome="$(echo "$postgresHome" | cut -d: -f6)"; \
12+
[ "$postgresHome" = '/var/lib/postgresql' ]; \
13+
mkdir -p "$postgresHome"; \
14+
chown -R postgres:postgres "$postgresHome"
715

816
# su-exec (gosu-compatible) is installed further down
917

9.6/alpine/Dockerfile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@
22
FROM alpine:3.5
33

44
# alpine includes "postgres" user/group in base install
5-
# /etc/passwd:22:postgres:x:70:70::/var/lib/postgresql:/bin/sh
6-
# /etc/group:34:postgres:x:70:
5+
# /etc/passwd:22:postgres:x:70:70::/var/lib/postgresql:/bin/sh
6+
# /etc/group:34:postgres:x:70:
7+
# the home directory for the postgres user, however, is not created by default
8+
# see https://github.com/docker-library/postgres/issues/274
9+
RUN set -ex; \
10+
postgresHome="$(getent passwd postgres)"; \
11+
postgresHome="$(echo "$postgresHome" | cut -d: -f6)"; \
12+
[ "$postgresHome" = '/var/lib/postgresql' ]; \
13+
mkdir -p "$postgresHome"; \
14+
chown -R postgres:postgres "$postgresHome"
715

816
# su-exec (gosu-compatible) is installed further down
917

Dockerfile-alpine.template

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@
22
FROM alpine:3.5
33

44
# alpine includes "postgres" user/group in base install
5-
# /etc/passwd:22:postgres:x:70:70::/var/lib/postgresql:/bin/sh
6-
# /etc/group:34:postgres:x:70:
5+
# /etc/passwd:22:postgres:x:70:70::/var/lib/postgresql:/bin/sh
6+
# /etc/group:34:postgres:x:70:
7+
# the home directory for the postgres user, however, is not created by default
8+
# see https://github.com/docker-library/postgres/issues/274
9+
RUN set -ex; \
10+
postgresHome="$(getent passwd postgres)"; \
11+
postgresHome="$(echo "$postgresHome" | cut -d: -f6)"; \
12+
[ "$postgresHome" = '/var/lib/postgresql' ]; \
13+
mkdir -p "$postgresHome"; \
14+
chown -R postgres:postgres "$postgresHome"
715

816
# su-exec (gosu-compatible) is installed further down
917

0 commit comments

Comments
 (0)