docker 實戰---使用oracle xe作為開發資料庫(六)

來源:互聯網
上載者:User

標籤:docker oracle

oracle作為oltp的大佬,很多行業應用都會用到它。那麼在開發的過程中就不可避免的要使用oracle資料庫,oracle資料庫的版本有好多,其中express版本是免費的開發版,它的主要限制是資料庫的大小最大1G,和一些效能的限制,所以拿來做開發還是比較合適的。

下面介紹下如何使用裝了oracle的 docker容器來進行開發:

首先,介紹一下docker-oracle這個image,他是在ubuntu的基礎上安裝oracle xe版本來完成的。

它的docker file如下:

FROM wnameless/xe-tempMAINTAINER Alexei Ledenev <[email protected]>ADD chkconfig /sbin/chkconfigADD init.ora /ADD initXETemp.ora /RUN apt-get install -y libaio1 net-tools bcRUN ln -s /usr/bin/awk /bin/awkRUN mkdir /var/lock/subsysRUN chmod 755 /sbin/chkconfigRUN ln -s /proc/mounts /etc/mtabRUN dpkg --install /tmp/oracle-xe_11.2.0-1.0_amd64.debRUN mv /init.ora /u01/app/oracle/product/11.2.0/xe/config/scriptsRUN mv /initXETemp.ora /u01/app/oracle/product/11.2.0/xe/config/scriptsRUN printf 8080\\n1521\\noracle\\noracle\\ny\\n | /etc/init.d/oracle-xe configureRUN echo 'export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe' >> /etc/bash.bashrcRUN echo 'export PATH=$ORACLE_HOME/bin:$PATH' >> /etc/bash.bashrcRUN echo 'export ORACLE_SID=XE' >> /etc/bash.bashrcEXPOSE 22EXPOSE 1521EXPOSE 8080CMD sed -i -E "s/HOST = [^)]+/HOST = $HOSTNAME/g" /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora;     service oracle-xe start;     /usr/sbin/sshd -D

放上這dockerfile的主要目的是為了看清它是怎樣建立的。

然後,pull一個已經裝好oracle xe的image。

docker pull alexeiled/docker-oracle-xe-11g


用新下載的image啟動一個oracle容器,開啟22 1521 8080 連接埠

docker run -d -p 22:22 -p 1521:1521 -p 8080:8080 alexeiled/docker-oracle-xe-11g

下面是一些容器的基本資料:

oracle:    
  sid xe
  system oracle
作業系統:    
  root admin
     

這樣我們就能用這個容器來進行開發了,比如一個項目需要3個oracle 伺服器:

docker run -d -p 101:22 -p 1521:1521 -p 8080:8080  --name oracle1 alexeiled/docker-oracle-xe-11g

docker run -d -p 102:22 -p 1522:1521 -p 8081:8080  --name oracle2 alexeiled/docker-oracle-xe-11g

docker run -d -p 103:22 -p 1523:1521 -p 8082:8080  --name oracle3 alexeiled/docker-oracle-xe-11g

啟動指令碼也可以簡單的寫成 docker start oracle1 oracle2 oracle3

這對於快速搭建帶oracle的開發環境還是有些益處的。

docker 實戰---使用oracle xe作為開發資料庫(六)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.