Я учусь использовать Docker, моя цель - создать контейнер Postgres SQL, в котором я создаю таблицу, на данный момент я не хочу добавлять какие-либо данные, просто создать таблицу.Я был в состоянии создать экземпляр sql postgres, но, кажется, скопировать / добавить мой сценарий sql (который создает эту таблицу) в /docker-entrypoint-initdb.d/ не работает.я могу подтвердить это, когда я запускаю psql db, я не вижу ни одной созданной таблицы.
Мой Dockerfile
"FROM ubuntu
RUN apt-get update && apt-get install -y gnupg
RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list
RUN apt-get update && apt-get install -y postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3
USER postgres
RUN /etc/init.d/postgresql start &&\
psql --command "CREATE USER docker WITH SUPERUSER PASSWORD 'docker';" &&\
createdb -O docker docker
RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.3/main/pg_hba.conf
RUN echo "listen_addresses='*'" >> /etc/postgresql/9.3/main/postgresql.conf
EXPOSE 5432
VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]
copy /scripts/test.sql /docker-entrypoint-initdb.d/
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"]"
Мой файл sql
CREATE TABLE email_confirmation_code (
id integer NOT NULL,
code character varying(255) NOT NULL,
user_id integer
);
test
psql -h localhost -p 32772 -U docker --password
Password for user docker:
psql (10.6 (Ubuntu 10.6-1.pgdg16.04+1), server 9.3.17)
SSL connection (protocol: TLSv1.2, cipher: DHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.
docker=# select * from email_confirmation_code
docker-# ;
ERROR: relation "email_confirmation_code" does not exist
LINE 1: select * from email_confirmation_code
, как вы видите, таблица не существует.пожалуйста, укажите, в чем здесь ошибка.