Reputation: 307
I'm not experienced with Docker and got stuck on one of my experiments with docker compose
. I'm trying to spin up an Oracle database (image: gvenzl/oracle-xe).
I also add two SQL scripts to the /docker-entrypoint-initdb.d/
directory, one to create a user and another one to create a table. When I perform the docker compose up
command, the logging shows that these scripts are picked up, and a user (of the first script) is indeed created. However, I cannot find my table anywhere when I connect to the running container with SQLDeveloper.
I have made a custom image where I use ADD
to place these files into the correct directory (not shown here, but confirmed that they are there). Below are the files that I'm using:
docker-compose.yml (just added line numbers for easy reference if something is wrong)
1 version: "3.8"
2
3 services:
4 db-oracle-xe:
5 build: .
6 restart: on-failure
7 image: oracle-xe:latest
8 environment:
9 ORACLE_PASSWORD: some_pass
10 APP_USER: someuser
11 APP_USER_PASSWORD: some_other_pass
12 volumes:
13 - some-data:/var/docker-data/oracle
14 ports:
15 - "1521:1521"
16
17 volumes:
18 some-data:
0-create-user.sql
CREATE USER TEST;
1-create-table.sql
1 create table TEST.SOME_TABLE
2 (
3 ID NUMBER(19) NOT NULL,
4 ADDED_DATE VARCHAR2(255 CHAR),
5 NAME VARCHAR2(255 CHAR) NOT NULL,
6 CREATED_TIME TIMESTAMP NOT NULL,
7 );
I'm completely stuck and would appreciate some feedback or perhaps tips on what I should do to troubleshoot this issue. It might be really simple what I'm doing wrong, so hoping to learn form this
Upvotes: 0
Views: 1425
Reputation: 395
You need to connect with username and password before creating tables.
check this blog for more details , it worked for me
Upvotes: 3