gpt4 book ai didi

oracle - 使用 docker-compose 安装 Oracle 数据库

转载 作者:行者123 更新时间:2023-12-05 05:07:48 24 4
gpt4 key购买 nike

我想使用 Oracle XE 启动一个 Docker 容器,然后运行 ​​SQL 脚本 (setup_database.sql) 在 docker-compose 中创建一些表。

如何将以下命令集成到我的 docker-compose 中:

docker run -d -p 49161:1521 -v "$PWD":/duo --name duodb --hostname duodb --network duo-test -e ORACLE_ALLOW_REMOTE=true wnameless/oracle-xe-11g-r2

在容器中运行一个终端:

docker exec -ti duodb /bin/bash

进入正确的目录:

cd duo/sql

启动 setup_database 脚本:

sqlplus system/oracle@xe @setup_database

我试过运行这个:

oracle:
container_name: duodb
image: wnameless/oracle-xe-11g-r2
ports:
- '49161:1521'
volumes:
- .:/duo
command: ["/bin/bash", "-c", "sqlplus system/oracle@xe @setup_database"]
environment:
- ORACLE_ALLOW_REMOTE=true

但这会输出以下错误:

Creating network "duo_default" with the default driver
Creating duodb
Creating duomail
Creating duolocal
Attaching to duomail, duodb, duolocal
duomail | MailDev webapp running at http://0.0.0.0:80
duomail | MailDev SMTP Server running at 0.0.0.0:25
duodb | /bin/bash: sqlplus: command not found
duodb exited with code 127
duolocal | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.20.0.3. Set the 'ServerName' directive globally to suppress this message
duolocal | [Fri Nov 15 08:17:55.944907 2019] [ssl:warn] [pid 1] AH01909: 172.20.0.3:443:0 server certificate does NOT include an ID which matches the server name
duolocal | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.20.0.3. Set the 'ServerName' directive globally to suppress this message
duolocal | [Fri Nov 15 08:17:55.977329 2019] [ssl:warn] [pid 1] AH01909: 172.20.0.3:443:0 server certificate does NOT include an ID which matches the server name
duolocal | [Fri Nov 15 08:17:55.980390 2019] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.1.32 OpenSSL/1.1.1d configured -- resuming normal operations
duolocal | [Fri Nov 15 08:17:55.980423 2019] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'

最佳答案

我不是那个 docker 专家,但据我所知,网络是自动创建的,所有容器都在 docker-compose 文件中,因此你不需要网络。此外,您可以为服务命名,因此我认为也不需要容器名称。您在哪个版本中启动撰写文件?你可以尝试这样的事情

version: "3"

services:
duodb:
image: wnameless/oracle-xe-11g-r2
ports:
- 49161:1521
volumes:
- .:/duo
environment:
ORACLE_ALLOW_REMOTE=true
MYSQL_ROOT_USER: root
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: my_database_name

关于oracle - 使用 docker-compose 安装 Oracle 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58872604/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com