前提・実現したいこと
コンテナを起動した際、create文を流したいのですが、上手くいきません。
コンテナちゃんと起動しています。
ご教授頂けますと幸いです。
該当のソースコード
version: '3' services: db: build: context: ./sql dockerfile: ./Dockerfile.pg container_name: postgresql restart: always environment: POSTGRES_USER: root POSTGRES_PASSWORD: admin PGPASSWORD: admin POSTGRES_DB: pg_tables TZ: "Asia/Tokyo" ports: - 5432:5432 volumes: - ./pg_data:/var/lib/postgresql/data - ./sql/init:/docker-entrypoint-initdb.d
./sql/init配下の1_create.sql
create table if not exists image ( id bigserial primary key, content_type varchar(32) not null, created_at timestamp not null default current_timestamp, status smallint not null, bin bytea default null );
コンテナ内のログ
The files belonging to this database system will be owned by user "postgres". This user must also own the server process. The database cluster will be initialized with locale "ja_JP.UTF-8". The default database encoding has accordingly been set to "UTF8". The default text search configuration will be set to "simple". Data page checksums are disabled. fixing permissions on existing directory /var/lib/postgresql/data ... ok creating subdirectories ... ok selecting dynamic shared memory implementation ... posix selecting default max_connections ... 100 selecting default shared_buffers ... 128MB selecting default time zone ... Asia/Tokyo creating configuration files ... ok running bootstrap script ... ok performing post-bootstrap initialization ... ok initdb: could not find suitable text search configuration for locale "ja_JP.UTF-8" sh: locale: not found 2021-11-29 22:58:50.010 JST [32] WARNING: no usable system locales were found syncing data to disk ... ok Success. You can now start the database server using: pg_ctl -D /var/lib/postgresql/data -l logfile start initdb: warning: enabling "trust" authentication for local connections You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb. waiting for server to start....2021-11-29 22:58:56.463 JST [38] LOG: starting PostgreSQL 14.1 on x86_64-pc-linux-musl, compiled by gcc (Alpine 10.3.1_git20210424) 10.3.1 20210424, 64-bit 2021-11-29 22:58:56.467 JST [38] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2021-11-29 22:58:56.491 JST [39] LOG: database system was shut down at 2021-11-29 22:58:53 JST 2021-11-29 22:58:56.510 JST [38] LOG: database system is ready to accept connections done server started CREATE DATABASE /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/1_create.sql CREATE TABLE waiting for server to shut down...2021-11-29 22:58:58.777 JST [38] LOG: received fast shutdown request .2021-11-29 22:58:58.781 JST [38] LOG: aborting any active transactions 2021-11-29 22:58:58.782 JST [38] LOG: background worker "logical replication launcher" (PID 45) exited with exit code 1 2021-11-29 22:58:58.791 JST [40] LOG: shutting down 2021-11-29 22:58:58.957 JST [38] LOG: database system is shut down done server stopped PostgreSQL init process complete; ready for start up. 2021-11-29 22:58:59.017 JST [1] LOG: starting PostgreSQL 14.1 on x86_64-pc-linux-musl, compiled by gcc (Alpine 10.3.1_git20210424) 10.3.1 20210424, 64-bit 2021-11-29 22:58:59.017 JST [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 2021-11-29 22:58:59.017 JST [1] LOG: listening on IPv6 address "::", port 5432 2021-11-29 22:58:59.024 JST [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" 2021-11-29 22:58:59.046 JST [54] LOG: database system was shut down at 2021-11-29 22:58:58 JST 2021-11-29 22:58:59.069 JST [1] LOG: database system is ready to accept connections
参考記事
https://qiita.com/chocomintkusoyaro/items/092bc8dd9ddf3a191261
回答1件
あなたの回答
tips
プレビュー