Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove volume expose #1560

Merged
merged 17 commits into from
Apr 1, 2020
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 30 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,42 @@ a pull request.
1. Extend an existing product image wherever possible. For example, if your
product requires WebLogic, then extend the WebLogic image instead of creating
your own WebLogic installation.
1. If you can't extend an existing image, your image must use the
gvenzl marked this conversation as resolved.
Show resolved Hide resolved
2. If you can't extend an existing image, your image must use the
`oraclelinux:7-slim` base image as this image provides the smallest
attack surface and is updated whenever a CVE errata is published.
1. Re-use existing scripts wherever possible. If a particular base image or
3. Re-use existing scripts wherever possible. If a particular base image or
script doesn't have the functionality you need, open an issue and work with
the image owner to implement it.
1. Specify a version in the `FROM` directive, i.e. use
4. Specify a version in the `FROM` directive, i.e. use
`FROM oraclelinux:7-slim` or `FROM java/serverjre:8`.
1. All images must provide a `CMD` or `ENTRYPOINT`. If your image is designed
5. All images must provide a `CMD` or `ENTRYPOINT`. If your image is designed
to be extended, then this should output documentation on how to extend the
image to be useful.
6. Use `LABEL` instructions for additional information such as ports and volumes. The following are common label instructions that should be present in all images where applicable:

| Label | Value | Applicability |
| -------- | ----- | ------------- |
| provider | The provider of the image (should be `Oracle Corporation` for base images in this repo) | All images |
gvenzl marked this conversation as resolved.
Show resolved Hide resolved
| issues | URL where issues and questions can be posted (should be `https://github.com/oracle/docker-images/issues` for base images in this repo | All images |
| maintainer | Name of the maintainer | All images |
gvenzl marked this conversation as resolved.
Show resolved Hide resolved
| volume(.`purpose`) | Use `volume` labels to describe the volumes of an image.<br/>If your image has multiple volumes, use qualified names to specify the purpose of each volume, for example `volume.data` for data to be persisted outside the container.<br/>Use hierarchical nesting for multiple volumes of the same type, for example:<br/><ul><li>`volume.data.dir1`</li><li>`volume.data.dir2`</li></ul> | For all images that have data that should be persisted outside the container |
| port(.`purpose`) | Use `port` labels to describe the ports of an image.<br/>If your images has multiple ports, use qualified names to specify the purpose of each port, for example `port.app` for the port on which your application is reachable.<br/>Use hierarchical nesting for multiple ports of the same type, for example:<br/><ul><li>`port.app.http`</li><li>`port.app.https`</li></ul> | For all images that have ports that should be exposed outside the container |

For example, for the Oracle Database 18c XE image we use the following labels:

```
LABEL "provider"="Oracle Corporation" \
gvenzl marked this conversation as resolved.
Show resolved Hide resolved
"issues"="https://github.com/oracle/docker-images/issues" \
"maintainer"="Gerald Venzl" \
gvenzl marked this conversation as resolved.
Show resolved Hide resolved
"volume.data"="/opt/oracle/oradata" \
"volume.setup.location1"="/opt/oracle/scripts/setup" \
"volume.setup.location2"="/docker-entrypoint-initdb.d/setup" \
"volume.startup.location1"="/opt/oracle/scripts/startup" \
"volume.startup.location2"="/docker-entrypoint-initdb.d/startup" \
"port.listener"="1521" \
"port.oemexpress"="5500" \
"port.apex"="8080"
```

### Security-related Rules

Expand All @@ -103,10 +128,6 @@ image to be useful.
on container startup using `openssl rand` or accept a password argument during
container startup (via `-e`).





### Guidelines and Recommendations

The following are some guidelines that will not prevent an image from being
Expand All @@ -130,4 +151,4 @@ any defaults that are used if no input is provided.
gracefully fail if that value is not provided.


*Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.*
*Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.*
gvenzl marked this conversation as resolved.
Show resolved Hide resolved
17 changes: 12 additions & 5 deletions OracleDatabase/SingleInstance/dockerfiles/11.2.0.2/Dockerfile.xe
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,18 @@
# ---------------
FROM oraclelinux:7-slim

# Maintainer
# ----------
MAINTAINER Gerald Venzl <gerald.venzl@oracle.com>
# Labels
# ------
LABEL "provider"="Oracle Corporation" \
"issues"="https://github.com/oracle/docker-images/issues" \
"maintainer"="Gerald Venzl" \
gvenzl marked this conversation as resolved.
Show resolved Hide resolved
"volume.data"="/u01/app/oracle/oradata" \
"volume.setup.location1"="/u01/app/oracle/scripts/startup" \
"volume.setup.location2"="/docker-entrypoint-initdb.d/setup" \
"volume.startup.location1"="/u01/app/oracle/scripts/setup" \
"volume.startup.location2"="/docker-entrypoint-initdb.d/startup" \
"port.listener"="1521" \
"port.apex"="8080"

# Environment variables required for this build (do NOT change)
# -------------------------------------------------------------
Expand Down Expand Up @@ -78,8 +87,6 @@ RUN yum -y install unzip libaio bc initscripts net-tools openssl compat-libstdc+
rm -rf $INSTALL_DIR && \
chmod ug+x $ORACLE_BASE/*.sh

VOLUME ["$ORACLE_BASE/oradata"]
EXPOSE 1521 8080
HEALTHCHECK --interval=1m --start-period=5m \
CMD "$ORACLE_BASE/$CHECK_DB_FILE" >/dev/null || exit 1

Expand Down
17 changes: 12 additions & 5 deletions OracleDatabase/SingleInstance/dockerfiles/12.1.0.2/Dockerfile.ee
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,18 @@
# ---------------
FROM oraclelinux:7-slim as base

# Maintainer
# ----------
MAINTAINER Gerald Venzl <gerald.venzl@oracle.com>
# Labels
# ------
LABEL "provider"="Oracle Corporation" \
"issues"="https://github.com/oracle/docker-images/issues" \
"maintainer"="Gerald Venzl" \
gvenzl marked this conversation as resolved.
Show resolved Hide resolved
"volume.data"="/opt/oracle/oradata" \
"volume.setup.location1"="/opt/oracle/scripts/setup" \
"volume.setup.location2"="/docker-entrypoint-initdb.d/setup" \
"volume.startup.location1"="/opt/oracle/scripts/startup" \
"volume.startup.location2"="/docker-entrypoint-initdb.d/startup" \
"port.listener"="1521" \
"port.oemexpress"="5500"

# Environment variables required for this build (do NOT change)
# -------------------------------------------------------------
Expand Down Expand Up @@ -107,8 +116,6 @@ RUN $ORACLE_BASE/oraInventory/orainstRoot.sh && \
USER oracle
WORKDIR /home/oracle

VOLUME ["$ORACLE_BASE/oradata"]
EXPOSE 1521 5500
HEALTHCHECK --interval=1m --start-period=5m \
CMD "$ORACLE_BASE/$CHECK_DB_FILE" >/dev/null || exit 1

Expand Down
17 changes: 12 additions & 5 deletions OracleDatabase/SingleInstance/dockerfiles/12.1.0.2/Dockerfile.se2
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,18 @@
# ---------------
FROM oraclelinux:7-slim as base

# Maintainer
# ----------
MAINTAINER Gerald Venzl <gerald.venzl@oracle.com>
# Labels
gvenzl marked this conversation as resolved.
Show resolved Hide resolved
# ------
LABEL "provider"="Oracle Corporation" \
"issues"="https://github.com/oracle/docker-images/issues" \
"maintainer"="Gerald Venzl" \
gvenzl marked this conversation as resolved.
Show resolved Hide resolved
"volume.data"="/opt/oracle/oradata" \
"volume.setup.location1"="/opt/oracle/scripts/setup" \
"volume.setup.location2"="/docker-entrypoint-initdb.d/setup" \
"volume.startup.location1"="/opt/oracle/scripts/startup" \
"volume.startup.location2"="/docker-entrypoint-initdb.d/startup" \
"port.listener"="1521" \
"port.oemexpress"="5500"

# Environment variables required for this build (do NOT change)
# -------------------------------------------------------------
Expand Down Expand Up @@ -107,8 +116,6 @@ RUN $ORACLE_BASE/oraInventory/orainstRoot.sh && \
USER oracle
WORKDIR /home/oracle

VOLUME ["$ORACLE_BASE/oradata"]
EXPOSE 1521 5500
HEALTHCHECK --interval=1m --start-period=5m \
CMD "$ORACLE_BASE/$CHECK_DB_FILE" >/dev/null || exit 1

Expand Down
17 changes: 12 additions & 5 deletions OracleDatabase/SingleInstance/dockerfiles/12.2.0.1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,18 @@
# ---------------
FROM oraclelinux:7-slim as base

# Maintainer
# ----------
MAINTAINER Gerald Venzl <gerald.venzl@oracle.com>
# Labels
# ------
LABEL "provider"="Oracle Corporation" \
"issues"="https://github.com/oracle/docker-images/issues" \
"maintainer"="Gerald Venzl" \
gvenzl marked this conversation as resolved.
Show resolved Hide resolved
"volume.data"="/opt/oracle/oradata" \
"volume.setup.location1"="/opt/oracle/scripts/setup" \
"volume.setup.location2"="/docker-entrypoint-initdb.d/setup" \
"volume.startup.location1"="/opt/oracle/scripts/startup" \
"volume.startup.location2"="/docker-entrypoint-initdb.d/startup" \
"port.listener"="1521" \
"port.oemexpress"="5500"

# Environment variables required for this build (do NOT change)
# -------------------------------------------------------------
Expand Down Expand Up @@ -104,8 +113,6 @@ RUN $ORACLE_BASE/oraInventory/orainstRoot.sh && \
USER oracle
WORKDIR /home/oracle

VOLUME ["$ORACLE_BASE/oradata"]
EXPOSE 1521 5500
HEALTHCHECK --interval=1m --start-period=5m \
CMD "$ORACLE_BASE/$CHECK_DB_FILE" >/dev/null || exit 1

Expand Down
17 changes: 12 additions & 5 deletions OracleDatabase/SingleInstance/dockerfiles/18.3.0/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,18 @@
# ---------------
FROM oraclelinux:7-slim as base

# Maintainer
# ----------
MAINTAINER Gerald Venzl <gerald.venzl@oracle.com>
# Labels
# ------
LABEL "provider"="Oracle Corporation" \
"issues"="https://github.com/oracle/docker-images/issues" \
"maintainer"="Gerald Venzl" \
gvenzl marked this conversation as resolved.
Show resolved Hide resolved
"volume.data"="/opt/oracle/oradata" \
"volume.setup.location1"="/opt/oracle/scripts/setup" \
"volume.setup.location2"="/docker-entrypoint-initdb.d/setup" \
"volume.startup.location1"="/opt/oracle/scripts/startup" \
"volume.startup.location2"="/docker-entrypoint-initdb.d/startup" \
"port.listener"="1521" \
"port.oemexpress"="5500"

# Environment variables required for this build (do NOT change)
# -------------------------------------------------------------
Expand Down Expand Up @@ -104,8 +113,6 @@ RUN $ORACLE_BASE/oraInventory/orainstRoot.sh && \
USER oracle
WORKDIR /home/oracle

VOLUME ["$ORACLE_BASE/oradata"]
EXPOSE 1521 5500
HEALTHCHECK --interval=1m --start-period=5m \
CMD "$ORACLE_BASE/$CHECK_DB_FILE" >/dev/null || exit 1

Expand Down
18 changes: 13 additions & 5 deletions OracleDatabase/SingleInstance/dockerfiles/18.4.0/Dockerfile.xe
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,19 @@
# ---------------
FROM oraclelinux:7-slim

# Maintainer
# ----------
MAINTAINER Gerald Venzl <gerald.venzl@oracle.com>
# Labels
# ------
LABEL "provider"="Oracle Corporation" \
"issues"="https://github.com/oracle/docker-images/issues" \
"maintainer"="Gerald Venzl" \
gvenzl marked this conversation as resolved.
Show resolved Hide resolved
"volume.data"="/opt/oracle/oradata" \
"volume.setup.location1"="/opt/oracle/scripts/setup" \
"volume.setup.location2"="/docker-entrypoint-initdb.d/setup" \
"volume.startup.location1"="/opt/oracle/scripts/startup" \
"volume.startup.location2"="/docker-entrypoint-initdb.d/startup" \
"port.listener"="1521" \
"port.oemexpress"="5500" \
"port.apex"="8080"

# Environment variables required for this build (do NOT change)
# -------------------------------------------------------------
Expand Down Expand Up @@ -68,8 +78,6 @@ RUN chmod ug+x $INSTALL_DIR/*.sh && \
rm -rf $INSTALL_DIR && \
chmod ug+x $ORACLE_BASE/*.sh

VOLUME ["$ORACLE_BASE/oradata"]
EXPOSE 1521 8080 5500
HEALTHCHECK --interval=1m --start-period=5m \
CMD "$ORACLE_BASE/$CHECK_DB_FILE" >/dev/null || exit 1

Expand Down
17 changes: 12 additions & 5 deletions OracleDatabase/SingleInstance/dockerfiles/19.3.0/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,18 @@
# ---------------
FROM oraclelinux:7-slim as base

# Maintainer
# ----------
MAINTAINER Gerald Venzl <gerald.venzl@oracle.com>
# Labels
# ------
LABEL "provider"="Oracle Corporation" \
"issues"="https://github.com/oracle/docker-images/issues" \
"maintainer"="Gerald Venzl" \
gvenzl marked this conversation as resolved.
Show resolved Hide resolved
"volume.data"="/opt/oracle/oradata" \
"volume.setup.location1"="/opt/oracle/scripts/setup" \
"volume.setup.location2"="/docker-entrypoint-initdb.d/setup" \
"volume.startup.location1"="/opt/oracle/scripts/startup" \
"volume.startup.location2"="/docker-entrypoint-initdb.d/startup" \
"port.listener"="1521" \
"port.oemexpress"="5500"

# Environment variables required for this build (do NOT change)
# -------------------------------------------------------------
Expand Down Expand Up @@ -101,8 +110,6 @@ RUN $ORACLE_BASE/oraInventory/orainstRoot.sh && \
USER oracle
WORKDIR /home/oracle

VOLUME ["$ORACLE_BASE/oradata"]
EXPOSE 1521 5500
HEALTHCHECK --interval=1m --start-period=5m \
CMD "$ORACLE_BASE/$CHECK_DB_FILE" >/dev/null || exit 1

Expand Down
65 changes: 18 additions & 47 deletions OracleDatabase/SingleInstance/samples/prebuiltdb/README.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,33 @@
# Example of creating an image with pre-built DB
***Warning: The description below requires changes in the dockerfile related to the version and edition in question (docker-images/OracleDatabase/SingleInstance/dockerfiles/$VERSION/Dockerfile). It's recommended that you revert the changes after you have completed creating image without VOLUME (see next section).***

## 1. Create an image without a VOLUME
## 1. Startup a container and create the database

When creating an image with a pre-build DB, we first need an image without a VOLUME. To create such an image you'll need to comment out the VOLUME command in the dockerfile in use (docker-images/OracleDatabase/SingleInstance/dockerfiles/$VERSION/Dockerfile).
First, you need to start up a container to get a database created. For this you will have to have the image already built.
gvenzl marked this conversation as resolved.
Show resolved Hide resolved

Comment out the following line:
```
#VOLUME ["$ORACLE_BASE/oradata"]
docker run --name oracle-build -p 1521:1521 -p 5500:5500 oracle/database:19.3.0-ee
```
In the example below I have edited the Dockerfile for version 12.2.0.1 and Enterprise Edition (ee) (docker-images/OracleDatabase/SingleInstance/dockerfiles/12.2.0.1/Dockerfile).

If you want to keep your existing image, you need to rename it:
```
docker tag oracle/database:12.2.0.1-ee oracle/database-org:12.2.0.1-ee
```

Then create an image without a VOLUME:
```
cd docker-images/OracleDatabase/SingleInstance/dockerfiles
sh buildDockerImage.sh -v 12.2.0.1 -e
```
## 2. Reset passwords (optional)

## 2. Startup a container and create the database
It's recommended to reset the passwords before creating the new prebuilt image. This way you don't have to reset it every time you create a new container.

We first need to start up a container to get the database created.
**Note:** First make sure you have built **oracle/database:12.2.0.1-ee**.
Now start the container as follow:
```
docker run --name oracle-build -p 1521:1521 -p 5500:5500 oracle/database:12.2.0.1-ee
```

## 3. Reset passwords (optional)

It's recommended to reset passwords before creating the image. This way you don't have to do it everytime you create a new container.

Now you should connect to the container and reset passwords:
Connect to the container and reset passwords:
```
docker exec oracle-build ./setPassword.sh <newPassword>
```
## 4. Stop the running container
## 3. Stop the running container

Stop the container (and therefore also the database) before generating your new prebuilt image:
```
docker stop -t 30 oracle-build
docker stop -t 600 oracle-build
```

## 5. Create the image with the prebuilt database
## 4. Create the image with the prebuilt database

Open a new console on your host and run the following command:
Create the new image via `docker commit`:
```
docker commit -m "Image with prebuilt database" oracle-build oracle/db-prebuilt:12.2.0.1-ee
docker commit -m "Image with prebuilt database" oracle-build oracle/db-prebuilt:19.3.0-ee
```

## 5. Clean up
Expand All @@ -59,41 +36,35 @@ Remove the temporary container:
```
docker rm oracle-build
```
Remove the image without VOLUME and rename the old image (if exists):
```
docker rmi oracle/database:12.2.0.1-ee
docker tag oracle/database-org:12.2.0.1-ee oracle/database:12.2.0.1-ee
```

Uncomment the volume instruction in your Dockerfile:
```
VOLUME ["$ORACLE_BASE/oradata"]
```
## 6. Ready to use your image with prebuild database

Run your prebuild image:

```
docker run --name <container-name> -p 1521:1521 -p 5500:5500 oracle/db-prebuilt:12.2.0.1-ee
docker run --name <container-name> -p 1521:1521 -p 5500:5500 oracle/db-prebuilt:19.3.0-ee
```

After the container is up and running you can connect to the new database.

You can also run your new image from a docker compose.
Create a directory, example "ora12c-db01", and add the following docker-compose.yml file:
Create a directory, for example `ora19c-db01`, and add the following docker-compose.yml file:

```
version: '2'
services:
orcl-node:
image: oracle/db-prebuilt:12.2.0.1-ee
image: oracle/db-prebuilt:19.3.0-ee
ports:
- "1521:1521"
- "5500:5500"
```

And run:

```
docker-compose up
```

# Copyright
Copyright (c) 2014-2017 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2014-2020 Oracle and/or its affiliates. All rights reserved.
gvenzl marked this conversation as resolved.
Show resolved Hide resolved
Loading