Closed
Description
Hello team.
The problem
I'm trying to create a proof of concept and, to do that, I need to create a Postgres DB and execute a small initialization script. I've followed, I think, the documentation, but the script isn't being executed. The message I get is this:
/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
When I login to the instance, the file /usr/local/bin/docker-entrypoint.sh
is indeed there and the script I'm passing is in the /docker-entrypoint-initdb.d/
folder.
drwxrwx--- 2 1000 1000 4096 Feb 27 10:47 .
drwxr-xr-x 1 root root 4096 Feb 27 13:17 ..
-rwxrwx--- 1 1000 1000 505 Feb 27 11:16 init.sql
Can you guys tell me what am I doing wrong?
What's the code
# docker-compose.yml
version: '3'
services:
db:
image: postgres:12.1-alpine
container_name: pgsql
restart: always
volumes:
- ./data/:/import_data/
- ./scripts/:/docker-entrypoint-initdb.d/
- /tmp/pgdata:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: example
ports:
- 5432:5432
-- ./scripts/init.sql
-- Create a new database called 'moviesshows'
CREATE TABLE Movies (
show_id INTEGER NULL,
title VARCHAR (1024) NULL,
director VARCHAR (1024) NULL,
actors TEXT NULL,
country VARCHAR (512) NULL,
date_added VARCHAR (256) NULL,
release_year SMALLINT NULL,
rating VARCHAR (50) NULL,
duration VARCHAR (128) NULL,
listed_in VARCHAR (1024) NULL,
plot TEXT NULL,
which VARCHAR (50) NULL
);
COPY movies FROM '/import_data/movies-shows.csv' delimiter ',' CSV HEADER;
# This is the file structure
.
├── data
│ └── movies-shows.csv
├── docker-compose.yml
└── scripts
└── init.sql
OS
I'm running an Ubuntu VM (Linux dev-vm 5.3.0-40-generic #32~18.04.1-Ubuntu SMP Mon Feb 3 14:05:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux) in VirtualBox (up-to-date).
Docker info:
Client:
Debug Mode: false
Server:
Containers: 2
Running: 2
Paused: 0
Stopped: 0
Images: 2
Server Version: 19.03.6
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339
runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
init version: fec3683
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 5.3.0-40-generic
Operating System: Ubuntu 18.04.4 LTS
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 7.776GiB
Name: dev-vm
ID: FBZ4:NL7C:3MHU:7O2I:3XB7:CIDI:MGEP:IYQB:5R2Y:2E7N:F5E7:KRZF
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Thanks