I built CloudStack to understand CloudStack, but I stumbled a bit at that time, so I decided to write this article. There are various ways to build CloudStack, but this time we will use Docker.
MacBook Pro (Mojave 10.14.6) Docker (19.03.13) docker-compose (1.27.4)
The CloudStack simulator is a Docker image officially provided by CloudStack. The simulator is running in one container except for the management DB. (Since I am not familiar with CloudStack, I would appreciate it if you could point out any mistakes.)
Since the image of the simulator is registered in Docker Hub, we will use it this time. https://hub.docker.com/r/cloudstack/simulator
docker pull cloudstack/simulator
docker run --name cloudstack -d -p 8080:8080 cloudstack/simulator
I tried to run it as officially and tried to access http: // localhost: 8080 / client, but an error occurred as shown in the image below. I didn't know what was happening just by looking at this, so I decided to check what kind of error was occurring.
docker run --name cloudstack -p 8080:8080 cloudstack/simulator
ERROR [c.c.u.d.Merovingian2](main:null) (logid:) Unable to get a new db connection
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
At first glance, it seems that you can't connect to MySQL? So, when I looked it up, I found issue regarding the above error.
However, since the issue was closed, I thought that the image of Docker Hub was old, so I decided to build it from the Latest release.
So, I will use Latest release of official repository. Files related to Docker are under tools / docker.
** Please clone as it is because you need files other than Docker related files at build time. ** **
Run Docker-compose. Probably, by executing this command, the management DB of CloudStack is started.
docker-compose -f tools/docker/docker-compose.yml up -d
Next, build the image from the Dockerfile, but if it is the cloned Dcokerfile, a pip error will occur, so fix it.
Dockerfile
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# CloudStack-simulator build
FROM ubuntu:16.04
MAINTAINER "Apache CloudStack" <[email protected]>
LABEL Vendor="Apache.org" License="ApacheV2" Version="4.13.1.0"
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get -y update && apt-get install -y \
genisoimage \
libffi-dev \
libssl-dev \
git \
sudo \
ipmitool \
maven \
openjdk-8-jdk \
python-dev \
python-setuptools \
python-pip \
python-mysql.connector \
supervisor
RUN apt-get install -qqy mysql-server && \
apt-get clean all && \
mkdir /var/run/mysqld; \
chown mysql /var/run/mysqld
RUN echo '''sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"''' >> /etc/mysql/mysql.conf.d/mysqld.cnf
COPY tools/docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY . ./root
WORKDIR /root
RUN ls
RUN mvn -Pdeveloper -Dsimulator -DskipTests clean install
#Please add this line
RUN pip install --upgrade pip
RUN find /var/lib/mysql -type f -exec touch {} \; && \
(/usr/bin/mysqld_safe &) && \
sleep 5; \
mvn -Pdeveloper -pl developer -Ddeploydb; \
mvn -Pdeveloper -pl developer -Ddeploydb-simulator; \
MARVIN_FILE=`find /root/tools/marvin/dist/ -name "Marvin*.tar.gz"`; \
pip install $MARVIN_FILE
VOLUME /var/lib/mysql
EXPOSE 8080 8096
CMD ["/usr/bin/supervisord"]
To make the image easier to understand, specify the same tag name as the CloudStack version and build it. If you can launch the container using the built image and access http: // localhost: 8080 / client, it is successful. It takes a long time to start up, so you may want to remove the -d option if you want to check if it is working properly.
docker build -t cloudstack/simulator:4.13.1.0 . -f tools/docker/Dockerfile
docker run --name cloudstack -d -p 8080:8080 cloudstack/simulator:4.13.1.0
This is the screen when you can access it.
I introduced it briefly in the article, but due to the lack of references, I made a lot of trial and error. I hope this article helps someone who is as stumbling as I am.
Recommended Posts