1

I'm trying to use the Dockerfile provided here and on building docker build . I get the error on line 69 (RUN createuser -s projop) which reports:

Step 15/27 : RUN /usr/bin/pg_ctl -D "/var/lib/pgsql/data" start
 ---> Using cache
 ---> ce049ebe4ff5

Step 16/27 : RUN sleep 60
 ---> Using cache
 ---> bf7bac638da6

Step 17/27 : RUN createuser -s projop                                                # database user "projop" with admin rights
 ---> Running in 700e6e618060
createuser: could not connect to database postgres: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

My inital thought was the the postgres server had not had enough time to start up from the lines before so I extended the sleep command up to 60 seconds, but I still got this same error.

I also opened a bash session with a intermediate container after the sleep with docker run -it bf7bac638da6 bash. Within this bash session I tried to manually run the createuser -s projop line which gave the same error.

However, if I reran the command /usr/bin/pg_ctl -D "/var/lib/pgsql/data" start and then createuser -s projop it would work.

This is quite od as it seems the initial start command is not taking effect. Any ideas what might be happening here?

Here's the full Dockerfile:

#
# Dockerfile for ]project-open[ V5.0 on CentOS 7
#

FROM centos:centos7

# ----------------------------------------------------------------------------------------------
# Install base packages
# ----------------------------------------------------------------------------------------------

RUN yum -y install wget net-tools setools
#RUN yum -y install cvs expat expat-devel pango graphviz-devel ImageMagick openldap-clients mlocate sharutils

# Install Perl libraries
#RUN yum -y install graphviz-perl perl perl-Archive-Tar perl-Archive-Zip perl-CGI perl-CGI-Session
#RUN yum -y install perl-CPAN perl-CPAN-Changes perl-CPAN-Meta perl-CPAN-Meta-Requirements perl-CPAN-Meta-YAML
#RUN yum -y install perl-Carp perl-Compress-Raw-Bzip2 perl-Crypt-DES perl-Crypt-OpenSSL-RSA
#RUN yum -y install perl-Crypt-OpenSSL-Random perl-Crypt-PasswdMD5 perl-Crypt-SSLeay perl-DBD-Pg
#RUN yum -y install perl-DBD-Pg-tests perl-DBI perl-Data-Dumper perl-DateTime perl-Digest-MD5
#RUN yum -y install perl-Encode perl-File-Slurp perl-GSSAPI perl-IO-Socket-IP perl-IO-Socket-SSL
#RUN yum -y install perl-JSON perl-LDAP perl-LWP-MediaTypes perl-LWP-Protocol-https perl-Net-DNS
#RUN yum -y install perl-Net-HTTP perl-Net-SSLeay perl-Params-Check perl-Params-Util perl-Params-Validate
#RUN yum -y install perl-Socket perl-TimeDate perl-WWW-Curl perl-YAML perl-core perl-devel perl-gettext
#RUN yum -y install perl-libs perl-libwww-perl rrdtool-perl perl-YAML
#RUN yum -y install libdbi-dbd-pgsql

# Install OpenOffice
#RUN yum -y install libreoffice libreoffice-headless



# ----------------------------------------------------------------------------------------------
# Download ]po[ distro files
# ----------------------------------------------------------------------------------------------

WORKDIR /usr/src/
RUN wget -q http://sourceforge.net/projects/project-open/files/project-open/Support%20Files/naviserver-4.99.8.tgz &&\
    wget -q http://sourceforge.net/projects/project-open/files/project-open/Support%20Files/web_projop-aux-files.5.0.0.0.0.tgz &&\
    wget -q http://sourceforge.net/projects/project-open/files/project-open/V5.0/update/project-open-Update-5.0.2.4.0.tgz


# ----------------------------------------------------------------------------------------------
# Create user projop and unpack ]po[ files an
# ----------------------------------------------------------------------------------------------

WORKDIR /usr/local
RUN tar xzf /usr/src/naviserver-4.99.8.tgz                              # extract the NaviServer binary 64 bit
RUN mkdir /web/                                                         # super-directory for all Web servers /web/ by default
RUN groupadd projop                                                     # create a group called "projop"
RUN useradd -d /web/projop -g projop projop                             # create user "projop" with home directory /web/projop
# RUN chown -R projop:projop /web/projop                                # set ownership to all files



# ----------------------------------------------------------------------------------------------
# Install PostgreSQL
# ----------------------------------------------------------------------------------------------

RUN yum -y install postgresql postgresql-server postgresql-contrib

# Run the rest of the commands as user postgres
USER postgres
RUN /usr/bin/pg_ctl -D "/var/lib/pgsql/data" initdb
RUN echo "host all  all    0.0.0.0/0  md5" >> /var/lib/pgsql/data/pg_hba.conf
RUN echo "listen_addresses='*'" >> /var/lib/pgsql/data/postgresql.conf
RUN /usr/bin/pg_ctl -D "/var/lib/pgsql/data" start
RUN sleep 60
RUN createuser -s projop                                                # database user "projop" with admin rights


# ----------------------------------------------------------------------------------------------
# Setup the /web/projop folder
# ----------------------------------------------------------------------------------------------

USER projop
WORKDIR /web/projop/
RUN tar xzf /usr/src/web_projop-aux-files.5.0.0.0.0.tgz                 # extract auxillary files
RUN tar xzf /usr/src/project-open-Update-5.0.2.4.0.tgz                  # extract the ]po[ product source code - latest
RUN createdb --encoding=utf8 --owner=projop projop                      # new database
# RUN createlang plpgsql projop                                         # enable PlPg/SQL, may already be installed

WORKDIR /web/projop
RUN psql -f /web/projop/pg_dump.5.0.2.4.0.sql > /web/projop/import.log 2>&1



# Expose the ]p[ and PostgreSQL port
EXPOSE 8000 5432

# Add VOLUMEs to allow backup of config, logs and databases
VOLUME  ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]

# Set the default command to run when starting the container
CMD ["/usr/lib/postgresql/9.3/bin/postgres", "-D", "/var/lib/postgresql/9.3/main", "-c", "config_file=/etc/postgresql/9.3/main/postgresql.conf"]
fraber
  • 1,204
  • 1
  • 8
  • 21
freebie
  • 2,161
  • 2
  • 19
  • 36
  • 1
    That Dockerfile does not reflect best practices and the RUN line in question is broken. If nothing else, running a container from the built image won't actually start any of the services it embeds, and it probably should be three separate containers in any case. I'd contact the maintainer of the site for support. – David Maze Aug 17 '18 at 10:38
  • @DavidMaze I had initially tried to make a docker compose before I stumbled on their Dockerfile. Having the database and the web service in the same container also rang strange to me. You say three containers, what's the third you are seeing? – freebie Aug 17 '18 at 10:43
  • The naviserver thing looks like a separate component the way the Dockerfile is laid out. I could see it potentially being a base layer for the main application. But absent any sort of CMD to start up this stack it's a little hard to tell. – David Maze Aug 17 '18 at 10:54

0 Answers0