简体   繁体   English

我如何从Oracle Docker容器装载数据?

[英]how can i mount data from oracle docker container?

i just want to start an oracle docker container with docker-compose.yml. 我只想使用docker-compose.yml启动一个oracle docker容器。
that works so far, till i added a folder to sync/mount/whatever from the container. 到目前为止,它一直有效,直到我添加了一个文件夹来同步/挂载/从容器中取出任何内容。

problem 1: if the folder on the host is missing - docker doesn't mount anything 问题1:如果主机上的文件夹丢失-泊坞窗不挂任何东西
problem 2: a empty folder is getting ignored by git - so i added an empty file .emptyfileforgit 问题2:git忽略了一个空文件夹-因此我添加了一个空文件.emptyfileforgit

So if i now start my docker-compose up, docker mounts the folder with my fake file to the oracle container, and so the database is "broken". 因此,如果现在启动docker-compose,docker会将带有假文件的文件夹安装到oracle容器,因此数据库“损坏”。

docker compose file: docker撰写文件:

version: "3" 版本:“ 3”
services: 服务:
mysql_db: mysql_db:
container_name: oracle_db container_name:oracle_db
image: wnameless/oracle-xe-11g:latest 图片:wnameless / oracle-xe-11g:latest
ports: 端口:
- "49160:22" -“ 49160:22”
- "49161:1521" -“ 49161:1521”
- "49162:8080" -“ 49162:8080”
restart: always 重启:总是
volumes: 数量:
- "./oracle_data:/u01/app/oracle/oradata" -“ ./oracle_data:/u01/app/oracle/oradata”
- "./startup_scripts:/docker-entrypoint-initdb.d" -“ ./startup_scripts:/docker-entrypoint-initdb.d”
environment: 环境:
- ORACLE_ALLOW_REMOTE=true -ORACLE_ALLOW_REMOTE = true

Question: how can i get rid of this behaviour? 问题:如何摆脱这种行为?
With a mysql container that works fine... 使用可以正常工作的mysql容器...

Thanks a lot! 非常感谢!

By using volume , folder/path/in/host : folder/path/in/container , the data in the container folder is mapped to provided location in the host. 通过使用volume, folder/path/in/host : folder/path/in/container ,容器文件夹中的数据将映射到主机中提供的位置。 Initially the db data is empty, that is why your host folder does not contain any data. 最初db数据为空,这就是为什么您的主机文件夹不包含任何数据的原因。 And do not put mock-invalid data in the db folder in your container. 并且不要将模拟无效数据放入容器的db文件夹中。 Because it will corrupt your db. 因为它将损坏您的数据库。 If you want to add dump db data, just put it in the folder of your host folder, it will mapped to the path in your container 如果要添加转储数据库数据,只需将其放在主机文件夹的文件夹中,它将映射到容器中的路径

您需要将文件复制到/ 0u1 / app / oracle / oradata中,然后才能从系统中容器的路径./orcle_data位置访问文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM