Skip to content

Commit

Permalink
Using --shm-size Docker option to mount shm.
Browse files Browse the repository at this point in the history
  • Loading branch information
bofm committed Mar 9, 2016
1 parent 2984ee0 commit c49b9af
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 37 deletions.
19 changes: 10 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
REPO = bofm/oracle12c
NAME = oracle
CURDIR = `pwd`
OPTS =
SHM_SIZE = 1GB
OPTS = --shm-size $(SHM_SIZE)
DOCKER_SAVE_FILENAME = docker_img_oracle_database_created_$$(date +%Y-%m-%d).tgz
ccred=\033[0;31m
ccgreen=\033[32m
ccyellow=\033[0;33m
ccend=\033[0m

.PHONY: all clean
.PHONY: all

# Use bofm/oracle12c:preinstall from Docker Hub
all: install postinstall
Expand Down Expand Up @@ -47,24 +48,24 @@ postinstall:
install:
@echo "$(ccgreen)Installing Oracle Database software...$(ccend)"
@if docker ps -a|grep $(NAME)_install; then docker rm $(NAME)_install; fi
@docker run --privileged --name $(NAME)_install -v $(CURDIR)/../database:/tmp/install/database $(REPO):preinstall /tmp/install/install.sh
@docker run $(OPTS) --name $(NAME)_install -v $(CURDIR)/../database:/tmp/install/database $(REPO):preinstall /tmp/install/install.sh
@echo "$(ccgreen)Committing image with tag 'installed'...$(ccend)"
@docker commit $(NAME)_install $(REPO):installed
@docker rm $(NAME)_install

run:
@docker run --rm $(OPTS) --name $(NAME) -i -t $(REPO) bash
@docker run -it --rm $(OPTS) --name $(NAME) $(REPO) bash

run-priv:
docker run -it --rm -v /data --privileged $(OPTS) --name $(NAME) $(REPO) bash --shm
run-v:
docker run -it --rm -v /data $(OPTS) --name $(NAME) $(REPO) bash

test:
docker run -it -v /data --privileged $(OPTS) --name oracle_db_test $(REPO) database --shm
docker run -it -v /data $(OPTS) --name oracle_db_test $(REPO) database
docker start -ia oracle_db_test
docker rm -v oracle_db_test

test2:
docker run -it -v /data --privileged $(OPTS) --name oracle_db_test $(REPO) database
docker run -it -v /data $(OPTS) --name oracle_db_test $(REPO) database
docker rm -v oracle_db_test

test3:
Expand All @@ -73,7 +74,7 @@ test3:

docker-save:
@echo "$(ccgreen)Running new container and creating database...$(ccend)"
docker run -d --privileged $(OPTS) --name oracle_db_test $(REPO) database --shm
docker run -d $(OPTS) --name oracle_db_test $(REPO) database
docker logs -f oracle_db_test &
@while true; do \
docker logs oracle_db_test 2>/dev/null | grep "Database created." && break || sleep 20; \
Expand Down
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* `docker logs` shows all the logs prefixed with log source (in the style of syslog).
* Uses `trap` to handle signals and shutdown gracefully.
* Data and logs go to `/data`, so that `-v /data` could be used.
* Mounts 50% of total memory to `/dev/shm` as shared memory. Oracle instance uses 40% of total memory. Can be changed in [entrypoint.sh](step2/entrypoint.sh) and [create_database.sh](step2/create_database.sh).
* Oracle instance uses 40% of total memory. Can be changed in [create_database.sh](step2/create_database.sh).
* rlwrap can be installed by running `bash /tmp/install/install_rlwrap.sh` (+ 50 MB on disk).


Expand All @@ -30,7 +30,7 @@ make all

```bash
# Create and start
docker run -d --privileged --name oracle_database -p 1521:1521 -v /data bofm/oracle12c
docker run -d --shm-size 1GB --name oracle_database -p 1521:1521 -v /data bofm/oracle12c
# Stop
docker stop -t 120 oracle_database
# Start again
Expand All @@ -41,7 +41,7 @@ make all
```bash
# Start
docker run -it --privileged --name oracle_database -p 1521:1521 -v /data bofm/oracle12c
docker run -it --shm-size 1GB --name oracle_database -p 1521:1521 -v /data bofm/oracle12c
# `ctrl+c` (SIGINT) to stop
```
Expand All @@ -61,9 +61,9 @@ make all
# Run the image in the new container
# Daemon
docker run -d --privileged --name oracle_database -p 1521:1521 bofm/oracle12c:created
docker run -d --shm-size 1GB --name oracle_database -p 1521:1521 bofm/oracle12c:created
# Foreground
docker run -it --privileged --name oracle_database -p 1521:1521 bofm/oracle12c:created
docker run -it --shm-size 1GB --name oracle_database -p 1521:1521 bofm/oracle12c:created
```
* Logs
Expand Down Expand Up @@ -108,15 +108,14 @@ make all
```
### Limitations and Bugs
* `--privileged` option is required to mount /dev/shm to use Oracle's automatic memory management.
* `--shm-size` option is required to mount /dev/shm to use Oracle's automatic memory management.
* Database options and sample schemas installation through DBCA is a mystery. In this repo dbca is run with `-sampleSchema true` and [db_template.dbt](step2/db_template.dbt) contains this line `<option name="SAMPLE_SCHEMA" value="true"/>`, but nothing happens, the database is always created without sample schemas. Well, that's Oracle Database after 30+ years of development.
### License
* This repo - [MIT License](LICENSE).
* Oracle Database software - see [Database Licensing Information](http://docs.oracle.com/database/121/DBLIC/toc.htm).
### TODO
* Remove `--privileged` and use `--shm-size` instead
* use spfile
* EM DBconsole
* Archivelog mode option?
Expand Down
8 changes: 4 additions & 4 deletions step2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ MAINTAINER bofm
RUN mkdir /data && chmod 777 /data
COPY db_template.dbt /tmp/
COPY colorecho /bin/
COPY entrypoint.sh /bin/
COPY entrypoint_oracle.sh /bin/
COPY create_database.sh ora_env /tmp/
RUN chmod +x /bin/entrypoint.sh /bin/entrypoint_oracle.sh /tmp/create_database.sh /tmp/ora_env /bin/colorecho
RUN chmod +x /bin/entrypoint_oracle.sh /tmp/create_database.sh /tmp/ora_env /bin/colorecho
ENV PATH=$PATH:/usr/bin:/usr/local/bin
EXPOSE 1521
ENTRYPOINT ["entrypoint.sh"]
CMD ["database", "--shm"]
USER oracle
ENTRYPOINT ["entrypoint_oracle.sh"]
CMD ["database"]
17 changes: 0 additions & 17 deletions step2/entrypoint.sh

This file was deleted.

0 comments on commit c49b9af

Please sign in to comment.