My docker container has no network options set, but i cant connect to it. This is my docker file:
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND noninteractive
# Install some tools
RUN apt-get update && apt-get install -y g++ clang-7 llvm-7 python make python2.7-dev bison flex libreadline-dev zlib1g-dev perl
COPY . /psql
RUN cd /psql && ./configure --with-llvm && make -j6 && make install && cd src/ext/ && make install-postgres-bitcode
RUN useradd -ms /bin/bash postgres && mkdir /data && chown postgres /data
# postgres as admin user
USER postgres
RUN /usr/local/pgsql/bin/initdb /data
# allow remote connections
VOLUME ["/data", "/usr/local/pgsql"]
# Set the default command to run when starting the container
EXPOSE 5432
CMD /usr/local/pgsql/bin/pg_ctl -D /data start
Please correct me if i am wrong, but right now, the docker container should have port 5432 open, and PostgreSQL maps by default to 5432, therefore, a connection on 5432 should get forwarded internally to PostgreSQL, right?
So to run it, i use this command:
docker run -p myContainer
But how to connect to the container now? I thought the docker container would be run on localhost, and i could therefore connect to it like this:
./psql -h localhost -p 5432 -U postgres
But i just get errors, that no host is listening or something ... what am i doing wrong?