Multi-Image Docker for Databases Images Failing




I created several Docker images with mock data that I’m trying to run inside CircleCI (2.0), so my tests have a database to connect to. I ended up going down the route of a multi-image setup:

      - image: circleci/node:7.10
      - image: private_repo/postgres:latest

Where the Postgres Docker image is a custom image (postgres:9.6.1-alpine base) with pre-loaded data (multi-stage Docker image where data is restored, and the resulting data directory is copied to a fresh Postgres image).

My issue is that while the custom Postgres image runs fine on my own device, it appears to have issues when being run inside CircleCI as a secondary image. I see a lot of lines like this output:

could not remove cache file "global/pg_internal.init": Permission denied

Again, these issues do not occur when I run this image elsewhere. Any ideas?

Extra: this is how I generate the custom Postgres image with pre-loaded data:

FROM postgres:9.6.1-alpine AS donor
ENV PGDATA=/pgdata
RUN mkdir /tmp/insert-data
COPY "data-fetch/data/*" "/tmp/insert-data/"
COPY "image_extend/*" "/docker-entrypoint-initdb.d/"
RUN chmod 755 /docker-entrypoint-initdb.d/*.sh
RUN / --help #all the data is loaded to this instance

FROM postgres:9.6.1-alpine
ENV PGDATA=/pgdata
COPY --from=donor /pgdata /pgdata


It ended up being a permission issue within the Postgres image - not CircleCI related at all!


@kbarresi How did you end up resolving the permission issue? I’m running into the same problem now.


I don’t remember exactly what I did, but we have a write-up on our engineering blog of how we did this. Let me know if that helps:


@kbarresi Thanks! Your post is really helpful! The key was to use the --chown flag in the last COPY command.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.