Creating ADempiere Instances with Docker

From ADempiere
Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken links.

Introduction

General

By: Mario Calderon
Docker is an open platform for developers and sysadmins to build, ship, and run applications.
With Docker, we can run locally an instance from the latest ADempiere revision directly from the sources, without having to download them or creating a development context.

Víctor Pérez created a Git project, where he configured everything to get ADempiere installed in a Docker container.
In the following lines, it will be explained how to get ADempiere running within a Docker container.
For Oracle and for Postgres there will be different Docker instances.

Docker can be installed on several operating systems; here an example on Suse 13.1 will be shown.
Docker is not intended to replace building a binary from Eclipse, nor downloading the official binary from SF. It is rather an additional alternative to get ADempiere for testing or demos.

As this is -at least for me- a novel tool, it is more than welcome that others try it out and document here their experiences with Docker.

Useful links

For a detailed explanation of how Docker works, the following links may be useful.

Installation

Installing Docker

Docker can be installed on several operating systems.
Please follow the link above to find the operating system where you want to run Docker.
Here, it will be shown how to install and run docker on a Suse 13.1.

Install Docker for SUSE 13.1

In the links above, you find the installation steps for different operating systems. Here we will follow the steps to install Docker on Suse 13.1
The steps were taken directly form the corresponding page.

  1. In console log in as root: su -
  2. zypper ar -f http://download.opensuse.org/repositories/Virtualization/openSUSE_13.1/ Virtualization
  3. rpm --import http://download.opensuse.org/repositories/Virtualization/openSUSE_13.1/repodata/repomd.xml.key
  4. zypper in docker
  5. Start the docker service: systemctl start docker
  6. User to group docker: /usr/sbin/usermod -a -G docker <myUserName>
  7. In case you need it, you can run Docker in a console as root: docker run --rm -i -t opensuse /bin/bash
  8. For other operating systems, follow the links stated above.

Clone Docker ADempiere project

Now that Docker is installed, we will clone the ADempiere project locally. Once cloned, we will be able to build the containers and run instances of them.

  1. Open a console as normal user
  2. Create directory for docker project: mkdir <myPath>/Adempiere/docker
  3. Go to this directory: cd <myPath>/Adempiere/docker
  4. Clone project created by Víctor Pérez : git clone https://github.com/adempiere/docker-adempiere.git

Instances Building

Build a Postgres instance

  1. In a console, log in as root: su - root
  2. Go to the repository directory for Postgres: cd <myPath>/Adempiere/docker/adempiere/dockerizing-adempiere-postgres
  3. Build the instance and give it a name (in this case adempiere/postgres:v380). Don't forget the "DOT" in the end: docker build -t=adempiere/postgres:v380 .
  4. it takes some minutes
  5. installs Postgres and Adempiere

Build an Oracle instance

  1. In a console, log in as root: su - root
  2. Go to the repository directory for Postgres: cd <myPath>/Adempiere/docker/adempiere/dockerizing-adempiere-oracle
  3. Build the instance and give it a name (in this case adempiere/oracle:v380). Don't forget the "DOT" in the end: docker build -t=adempiere/oracle:v380 .
  4. it takes some minutes
  5. installs Oracle and Adempiere

Running instances

Run a Postgres instance

  1. Run an instance with ports set manually: docker run -d -h adempiere-postgres -p 59160:22 -p 59161:1571 -p 59163:80 -p 59164:443 adempiere/postgres:v380
  2. Run an instance with ports automatically set: docker run -d -h adempiere-postgres -P adempiere/postgres:v380

Result for example

  • 49173:80 -p 49174:443 adempiere/postgres:v380
  • f5689692a1902ee9c19e94c8cbdbace29575c502fb66abb03e2de23e7c0c7f50
  • h, --hostname="Container host name" here it MUST BE "adempiere-postgres", because it is so defined in Docker
  • Image: adempiere/postgres:v380
  • A memory instance (non-persistence) is created (e.g. c03ed03d76e531fbe144a0eaf7b6ed0fad9aae84369ccc89d23a9ed882f58c91)
  • Note the local ports have been redirected to the instance. For example, port 59163 goes to the instance's port 80
  • Adempiere was installed under /data2/app/Adempiere/

Run an Oracle instance

  1. Run an instance with ports set manually: docker run -d -h adempiere-oracle -p 49160:22 -p 49161:1521 -p 49162:8080 -p 49163:80 -p 49164:443 adempiere/oracle:v380
  2. Run an instance with ports automatically set: docker run -d -h adempiere-oracle -P adempiere/oracle:v380
  3. -h, --hostname="Container host name" here it MUST BE "adempiere-oracle", because it is so defined in Docker
  4. Image: adempiere/oracle:v380
  5. A memory instance (non-persistence) is created (e.g. c03ed03d76e531fbe144a0eaf7b6ed0fad9aae84369ccc89d23a9ed882f58c91)
  6. Note the local ports have been redirected to the instance. For example, port 49163 goes to the instance's port 80
  7. Adempiere was installed under /u01/app/Adempiere/


To correct Oracle configuration (meanwhile it is not corrected in the Git project)

  • cat /u01/app/oracle/product/11.2.0/xe/network/admin/tnsnames.ora
  • cat /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora
  • sed -i -E "s/HOST = [^)]+/HOST = adempiere-oracle/g" /u01/app/oracle/product/11.2.0/xe/network/admin/tnsnames.ora
  • sed -i -E "s/HOST = [^)]+/HOST = adempiere-oracle/g" /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora
  • sed -i -E "s/-Xms64M/-Duser.timezone=GMT -Xms64M/g" myEnvironment.sh
  • tnsping XE

Log in into an instance

  • Usage: ssh root@<IP of instance> -p <forwarded port 22>
    • <IP of instance> found by: ifconfig or docker inspect $(docker ps -q) | grep IPA
    • <forwarded port 22> set by "docker build ..." and seen with "docker ps"

Log in into a Postgres instance

  • In console: ssh root@<IP of instance> -p 59160
  • Or (if there is only one instance running): ssh root@localhost -p 59160
  • password of postgres instance: adempiere
  • start Postgres: service postgresql start

Log in into a Oracle instance

  • In console: ssh root@<IP of instance> -p 49160
  • password of oracle instance: admin
  • Start Oracle: service oracle-xe restart

Run ADempiere

  • First: update database
    • Postgres: cd /data/app/Adempiere/utils
    • or Oracle: cd /u01/app/Adempiere/utils
    • Actual update: ./RUN_ImportAdempiere.sh
  • Delete output file: rm nohup.out
  • Run Application Server
    • nohup ./RUN_Server2.sh &
    • to see output of server: cat nohup.out | more
  • Test Adempiere
    • Open a Browser: <IP of instance>:<forwarded port 80>

Images

  • Save a snapshot
    • Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
    • e.g.: docker commit -m "Postgres instance" -a "ADempiere team" 13da4fe883a1 adempiere/postgres:v380
    • result: a string like "5fed353ede7c11f787143a0b1f95fbfa024004f1ea81a258e4ad7e86a8b5be1c"
  • Start image
    • Oracle: docker start adempiere/oracle:v380
    • Postgres: docker start adempiere/postgres:v380

Useful Docker commands

  • To see status of instace: docker ps
    • Example of information displayed
      • CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
      • c03ed03d76e5 adempiere/oracle:v380 "/bin/sh -c '/usr/sb 20 hours ago Up 20 hours 0.0.0.0:49160->22/tcp, 0.0.0.0:49161->1521/tcp, 0.0.0.0:49162->8080/tcp, 0.0.0.0:49163->80/tcp, 0.0.0.0:49164->443/tcp agitated_perlman
  • General information of Docker: docker info
    • output for example
      • Containers: 9
      • Images: 129
      • Storage Driver: devicemapper
      • Pool Name: docker-8:18-3147211-pool
      • Pool Blocksize: 65.54 kB
      • Data file: /var/lib/docker/devicemapper/devicemapper/data
      • Metadata file: /var/lib/docker/devicemapper/devicemapper/metadata
      • Data Space Used: 9.26 GB
      • Data Space Total: 107.4 GB
      • Metadata Space Used: 9.679 MB
      • Metadata Space Total: 2.147 GB
      • Library Version: 1.03.01 (2011-10-15)
      • Execution Driver: native-0.2
      • Kernel Version: 3.11.10-17-desktop
      • Operating System: openSUSE 13.1 (Bottle) (x86_64) (containerized)
  • To find IP of instace: docker inspect $(docker ps -q) | grep IPA
    • Result: "IPAddress": "172.17.0.40",
  • Stop docker container: docker stop <container_id>, e.g. docker stop 9aad97a1115d
  • Start docker container: docker start <container_id>, e.g. docker start 13da4fe883a1
  • Help: docker --help
    • Run 'docker COMMAND --help' for more information on a command.
    • docker run --help
    • docker build --help
  • IP of instace: docker inspect $(docker ps -q) | grep IPA
    • Result similar to "IPAddress": "172.17.0.3",