Install as a Docker Container

Databases can be difficult to install. Docker can make it easy. To get some informal information, check out the .
lac311
You can install and configure 
CA Live API Creator
 to run as a Docker container.
In this article:
Verify the Prerequisites
Ensure that you have completed the following prerequisites before installing
CA Live API Creator
 to run as a Docker container:
  • You have installed a recent version of Docker (1.11 or newer on Linux and 1.12.3 or later on Mac/Windows) and it is running properly.
    For more information about installing and running Docker, see the Docker documentation.
To verify your Docker version and verify if Docker is running properly, run the following command from the command line:
docker info
The output gives you information about your version of Docker.
 If you get an error message, do not continue with installing and configuring 
CA Live API Creator
 to run as a Docker container.
 
  • You have decided which port you would like API Creator to run on. This installation assumes that that port is 8080, but you can change that to any port you want (as long as it is greater than 1024, less than 65535, and not already in use).
The One-minute Version
You can run
CA Live API Creator
in non-persistent mode using the one-minute version. This method starts a Docker container with
CA Live API Creator
running on Apache Tomcat, using Derby as the admin database and for its sample databases.
The Docker container does not remember anything, so do not invest too much time into it. Non-persistent mode is the simplest, but least powerful, way to run
CA Live API Creator
 as a Docker container.
 
  • Derby as an admin database is supported only for demonstration and proof of concept (POC) purposes. Using Derby as your admin database limits your ability to upgrade to the next
    CA Live API Creator
    release.
  • Using Derby as your admin database is for advanced users.
  • Limitations:
    CA Live API Creator
    supports Derby only in embedded mode. In this mode, Apache Derby does not support cluster configurations. Only one server can access the database at any given time.
  1.  Issue the following command:
    docker run -p 8080:8080 caliveapicreator/3.1.1
  2. Start API Creator using the following URL in a browser: 
    http://localhost:8080/APICreator
  3. Log in with user name
    admin
    , password
    Password1
    .
You are logged in to API Creator and up and running.
Decide How you Want to Run the Container
You can run
CA Live API Creator
 as a Docker container using the following deployment methods:
  • Non-persistent mode.
     The Docker container does not remember anything. If you restart the container, any changes you have made, and any APIs you might have created, are forgotten. This is useful for quick demos, training, etc., or when you want a clean slate every time you start the image, and you do not plan to keep any changes.
  • Persistent mode
    .
    The Docker container stores its information on the host's file system. If you restart the container, your changes are remembered. This deployment method is useful when using
    CA Live API Creator
    for an extended period of time and you want to keep the changes you make.
  • MySQL mode
    .
    The Docker container stores its information in a MySQL database, without any samples pre-installed. This is typically the mode used for production. You can use this deployment method in a cluster.
: In all cases, if you want to avoid the End User License Agreement screen and having to accept the End User License Agreement when you first connect to
CA Live API Creator
, you can start the Docker container using the following parameter:
docker run -p 8080:8080 
-e ca_accept_license=enu
 caliveapicreator/3.1.1
Run the Container in Non-Persistent Mode
You can run 
CA Live API Creator
 as a Docker container in non-persistent mode using the following methods:
There are many options when running 
CA Live API Creator
 a Docker container.
For more information about these options, see the Docker documentation.
  • Start the Docker container. Issue the following command:
    docker run \
            -p 8080:8080 \
            caliveapicreator/3.1.1
    This command does not return and shows you the output of the container. This is usually helpful for diagnosing problems.
  • Run the Docker container in the background. Issue the following command, adding the 
    -d
     option:
    docker run \         -d \         -p 8080:8080 \         caliveapicreator/3.1.1
Run the Container in Persistent Mode
Decide where you want the Docker container to store its information. On Windows and Mac, the storage is in the Docker Machine, but you can share a directory between the host machine and the Docker Machine.
For more information about the Docker Machine, see the Docker documentation.
This procedure assumes the directory that you will use is 
/home/docker/LiveAPICreator
.
Issue the following command:
 
docker run \         -p 8080:8080 \         --volume=/home/docker/LiveAPICreator:/usr/local/CALiveAPICreator \         caliveapicreator/3.1.1
The
/home/docker/LiveAPICreator
 path is a default. You can change this path but this path should work in most cases. This directory is not deleted from the Docker Machine if you delete the 
CA Live API Creator
 Docker image. You must remove it. The first time you run the container in this mode, the following message appears:
 
Databases not found -- initializing with default
This message indicates that the repository was not found, and therefore a default repository was created, pre-loaded with two sample APIs.
Run the Container in MySQL Mode
When you run 
CA Live API Creator
 as a Docker container using this mode, 
CA Live API Creator
 uses a MySQL database as the admin database. You can provide your own MySQL database or you can use a pre-configured Docker container.
In this configuration, sample APIs are not created. You can change these options to use a pre-existing MySQL installation instead of a Docker container.
This procedure assumes that the directory you use to store the MySQL data is 
/home/docker/lacadmin
 (this directory must exist in your Docker machine). You can specify a different directory, but it must be writable and the underlying disk must have enough free space.
  1.  Start the MySQL Docker container by issuing the following command:
    docker run \         -e MYSQL_ROOT_PASSWORD=Password1 \         -e MYSQL_DATABASE=lacadmindb \         -e MYSQL_USER=lacadminuser \         -e MYSQL_PASSWORD=Password2 \         --volume=/home/docker/lacadmin:/var/lib/mysql \         -p 3306:3306 \         mysql:5.6.29
    Recent versions of MySQL should work, but MySQL 5.6.29 is known to work.
    The MySQL Docker container is now up and running. The startup process can take 10-20 seconds after the container is downloaded.
  2. Start 
    CA Live API Creator
     as a Docker container by issuing the following command:
    docker run \
            -e RDS_HOSTNAME=127.0.0.1 \
            -e RDS_PORT=3306 \
            -e RDS_USERNAME=lacadminuser \
            -e RDS_PASSWORD=Password2 \
            -e RDS_DB_NAME=lacadmindb \
            -e LAC_ADMIN_MAX_CONN=100 \
            -p 8080:8080 \
            caliveapicreator/3.1.1
    The Docker container can take a few seconds to start up.
Connect to API Creator
After the Docker container is up, connect to it from your Web browser:
http://localhost:8080/APICreator
By default, the user name is
admin
and the password is
Password1
.
Enable Other Options at Container Startup
You can enable the following options by specifying parameters:
  • Bypass the additional step at initial login to API Creator of having to accept the CA End User License Agreement (EULA).
  • Have the Docker container use your license file instead of its built-in license file.
When you first log in to API Creator, you are asked to accept the CA EULA. You can bypass this additional step when you start the Docker container by specifying the following parameter on the command line:
-e ca_accept_license=ENU
The Docker container uses a built-in default license file. You can pre-load your own license file by specifying the following parameter on the command line when you start the Docker:
-e LAC_DEFAULT_LICENSE_FILE=/licenses/MyLicense.txt 
The path used in the command is from the perspective of the Docker container. You can map a volume to make the license file available to the Docker container, for example:
--volume=/Users/jdoe/licensing:/licenses -e LAC_DEFAULT_LICENSE_FILE=/licenses/MyLicense.txt
Examine the Container
Prerequisite:
The Docker container is running.
 You can examine the Docker container.
  1.  Issue the following command:
    docker ps
    The following result is expected:
    CONTAINER ID        IMAGE                          COMMAND                  CREATED      
    9376d7985de1        caliveapicreator/3.1.1         "catalina.sh run"        4 minutes ago
  2. Copy the Docker container ID.
  3. Start a shell in the container by issuing the following command:
    docker exec -i -t 9376d7985de1 bash
    A command prompt appears. Tomcat runs in the 
    /usr/local/tomcat
     directory. If you are running 
    CA Live API Creator
     as a Docker container in non-persistent mode or persistent mode, the various Derby databases are in the
    /usr/local/CALiveAPICreator/databases
     directory.
    The keystore for Tomcat running as a Docker container is the
    /usr/local/tomcat/conf/keystore
    file.
Stop and Reset your Container
If you want to stop your Docker container(s), complete the following:
The commands are in blue.
  1. Find the Docker container ID by issuing the following command:
    $ docker ps
    The following response is expected:
    CONTAINER ID    IMAGE                   COMMAND                    CREATED            STATUS           PORTS
    ac7660d368e5    mysql:5.6.29            "/entrypoint.sh mysql"     31 seconds ago     Up 30 seconds    3306/tcp
    547911c7c2cc
     
       caliveapicreator/3.1.1  "StartLiveAPICreator."     7 minutes ago      Up 7 minutes     0.0.0.0:8080->8080/tcp
  2. Complete one of the following:
    • Stop the Docker container by issuing the following command:
      docker stop 
      547911c7c2cc
    • Stop the Docker container permanently by issuing the following command:
      docker rm 
      547911c7c2cc
To wipe the Docker container out completely, complete the following:
  1. Find the
    CA Live API Creator
    's Docker image ID by issuing the following command:
    $ docker images
    The following response is expected:
    REPOSITORY                                   TAG                           IMAGE ID                  CREATED                SIZE
    caliveapicreator/3.1.1     latest          
    96b2a3d11452
     
       2 days ago     580.4 MB
    mysql                      5.6.29          cf859bd8ff7f    3 weeks ago    324.2 MB
  2. Remove the image by issuing the following command:
    $ docker rmi 96b2a3d11452
Databases
Databases can be difficult to install. Docker can make it easy. To get some informal information, check out the Tech Blog.