Building and Running APPC Docker Images
Assumptions
This guide assumes the following:
You have a Linux virtual machine where you are currently able to build the appc code
Your virtual machine should have adequate resources to run the appc Docker images
The Docker images can run in a virtual machine with 4GB of ram, but if you are also running Eclipse, it might be a good idea to configure 6GB or more
You should give the virtual machine at least 2, possibly 3 or 4 processor cores
Some of the steps in this guide may only work on newer versions of Linux. In this case, you may see a section in red which has steps to use for an older version.
Where to install Docker
You can either run Docker on the same VM that you are using for maven and other development work, or you can install Docker in its own VM. There is less network configuration to be done if Docker is installed in the same VM as your maven builds. In this guide, we will look at installing Docker in the same VM that you are using for builds.
Installing Docker Services
The Docker service is installed on Linux from the package manager. It is available for most Linux distributions.
Install on Ubuntu: sudo apt-get install docker.io
Install on Centos/Redhat: sudo yum install docker
Make sure Docker is set to start
sudo systemctl enable docker
sudo systemctl start docker
For older Linux versions (Ubuntu 1404):
sudo service docker start
Allow Docker to run without root
Note: This could be considered a security risk because your account will basically have root access when it’s in the docker group
sudo groupadd docker
sudo usermod -aG docker $USER
sudo shutdown now -r
Test Docker install
You can test your install by running docker version
Setup proxy server for Docker
Create a new directory for Docker service:
sudo mkdir /etc/systemd/system/docker.service.d
Create a new file in the new directory called “http-proxy.conf” with the following contents:
[Service]
Environment=”HTTP_PROXY=<put proxy address here>/”
Reload Docker
sudo systemctl daemon-reload
sudo systemctl restart docker
For Older Linux (Ubuntu 1404):
Edit the file “/etc/default/docker”
Uncomment the line that begins with “export http_proxy”
Replace the proxy address on the same line with the address of your proxy server
Restart Docker:
sudo service docker restart
Installing docker-compose
We normally use the docker-compose utility to bring up the appc Docker images.
It can be installed with: sudo apt-get install docker-compose
Depending on your Linux version and repository setup, docker-compose may not be available from the package manager.
Python pip can also be used to install docker compose:
sudo pip install docker-compose
If pip is not installed, it should be able to be installed with:
sudo apt-get install python-pip
The full install guide for docker-compose can be found on the Docker website: https://docs.docker.com/compose/install/
Preparing for Docker Build in Maven
You need to make sure that you have an entry in your maven “settings.xml” file for your local maven repository. This way, when you run the Docker build, it will be able to download the appc installers from your local computer instead of going out to nexus server.
By default, your maven settings file will be in your Linux home folder, in the .m2 folder (~/.m2/settings.xml)
You’ll want to add a repository entry pointing to your local .m2/repository folder
The local repository entry looks like the following, it should go in the <repositories> tag in the settings file. You need to put your Linux user id in the placeholder.
<repository>
<id>local-maven</id>
<name>local-maven</name>
<url>file:///home/<Linux user id>/.m2/repository</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>local-maven</id>
<name>local-maven</name>
<url>file:///home/<Linux user id>/.m2/repository</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
Cloning the appc deployment project
The appc deployment project contains the maven files which will build the Docker image.
Clone this repository. (git clone
https://gerrit.onap.org/r/appc/deployment)
Downloading the pre-requisite Docker images
Our appc image is based on the ccsdk odlsli Docker image. So we need to download this before building the appc Docker image.
First, you need to login Docker to the onap repository
docker login
nexus3.onap.org:10001
Use your Linux Foundation credentials for the login
Note: It appears that if you guess your password too many times, you will be locked out.
Now we pull down the image
At the time of this writing, the latest version of the ccsdk-odlsli-image is “v0.1.0”, but this could change in the future
Pull the image with:
docker pull
nexus3.onap.org:10001/onap/ccsdk-odlsli-alpine-image:0.4.1 (For Dublin Release)
Once it is done, we need to tag this image with the correct name that the appc build will be expecting:
docker tag
nexus3.onap.org:10001/onap/ccsdk-odlsli-alpine-image:0.4.1 onap/ccsdk-odlsli-alpine-image:0.4.1
Building with Maven on the command line
The first step is to build the main appc project.
This must be done on the same system that you will be building the Docker image on
Go to your appc folder in a terminal
Run
mvn clean install
Once this has completed, we will do a Docker build on the deployment project
Go to your deployment project folder in a terminal
mvn clean install -P docker
Checking that the new Docker image was created
The command docker images
will show all the Docker images that you have on your system. You should see an image called “onap/appc-image” that was created recently (when you ran the build).
Starting the new Docker image
Note: Starting up the Docker containers from behind a proxy server usually does not work. We have had several experimental methods to make it work, but none have proven to be reliable.
By default, the docker-compose command will use the “docker-compose.yml” file from the current directory that you run the command from as its configuration.
Open a terminal window in the “docker-compose” directory of the appc deployment git repository that you cloned earlier
We want to slightly modify the docker-compose.yml file in this directory
In the file, you will see a “dgbuilder:” line
Remove this line and everything below it and save the file.
Note: If you plan to use the dg-builder, you will want to skip this step. But, if you don’t plan to use it, it will save time and memory to remove it
From the same directory containing the docker-compose.yml file, run the command
docker-compose up -d
This will create and start up the appc Docker containers
You can run the
docker-compose logs
command to see the startup log.Once the log displays the Opendaylight logo, you know startup is complete. It will take a few minutes.
Opening the Opendaylight api doc explorer
From a browser on the same VM where you have Docker running:
The username is "admin", password is "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"
Commands while running the Docker image
| Shows the statup log for the containers. This is a good way to check if startup is complete. |
| Shows all running Docker containers |
| Shows all running and stopped Docker containers |
| Stops a running Docker container |
| Deletes a Docker container and its associated volume (does not delete the Docker image that was used to bring up the container) |
| This will stop all running Docker containers |
| This will delete all created Docker containers (will not delete the Docker image files) |
| Opens the bash shell in the running appc Docker container. The exit command will allow you to leave the Docker container. |
| Directly opens the opendaylight console that is running in the Docker container |
| List all of the Docker images that are on your system. Shows their name, version, id, size, and date. |
| Delete the Docker image off your system with the given image id |
Accessing the MySQL database Docker container
Once the Docker containers are running, you can directly access the mysql database with this command: docker exec -it sdnc_db_container mysql -uroot -popenECOMP1.0