Operations 5 min read

Step-by-Step Guide to Installing Docker, MySQL, and Apollo Services on CentOS

This tutorial provides detailed commands and configurations for installing a specific Docker version, setting up persistent MySQL containers, importing Apollo database scripts, and deploying Apollo Config, Admin, and Portal services using Docker on a CentOS host.

Practical DevOps Architecture
Practical DevOps Architecture
Practical DevOps Architecture
Step-by-Step Guide to Installing Docker, MySQL, and Apollo Services on CentOS

This article presents a comprehensive, command‑by‑command guide for installing a specific Docker version, preparing MySQL data directories, pulling MySQL and Apollo images, and configuring Apollo Config Service, Admin Service, and Portal Server on a CentOS machine.

Install Docker and required utilities:

yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum list docker-ce --showduplicates | sort -r
yum -y install docker-ce-18.06.3.ce-3.el7
systemctl start docker

Create MySQL data directories and set ownership:

mkdir /data/mysql/conf/ -pv
mkdir /data/mysql/logs
mkdir /data/mysql/mysql
chown -R mysql.mysql /data/mysql

Pull the MySQL image and run the container with volume mounts and root password:

docker pull mysql:8.0.19
docker run -d --name mysql8.0.19 --restart always -p3306:3306 \
  -v /data/mysql/conf/my.cnf:/etc/mysql/my.cnf \
  -v /data/mysql/logs:/logs \
  -v /data/mysql/mysql:/var/lib/mysql \
  -e MYSQL_ROOT_PASSWORD=123456 \
  mysql:8.0.19

Enter the MySQL container and import the Apollo SQL scripts:

docker exec -it 3b0fd3fcbae2 /bin/bash
cd /var/lib/mysql
mysql> source /var/lib/mysql/mysql/apolloportaldb.sql
mysql> source /var/lib/mysql/mysql/apolloconfigdb.sql

Pull and run the Apollo Config Service container with required environment variables:

docker pull apolloconfig/apollo-configservice
docker run -d \
  --name apollo-configservice \
  --net=host \
  -v /tmp/logs:/opt/logs \
  -e SPRING_DATASOURCE_URL="jdbc:mysql://192.168.20.57:3306/ApolloConfigDB?characterEncoding=utf8" \
  -e SPRING_DATASOURCE_USERNAME=root \
  -e SPRING_DATASOURCE_PASSWORD=123456 \
  apolloconfig/apollo-configservice

Pull and run the Apollo Admin Service container (using the same configuration as Config Service):

docker pull apolloconfig/apollo-adminservice
docker run -d --name apollo-adminservice \
  --net=host \
  -v /tmp/logs:/opt/logs \
  -e SPRING_DATASOURCE_URL="jdbc:mysql://192.168.20.57:3306/ApolloConfigDB?characterEncoding=utf8" \
  -e SPRING_DATASOURCE_USERNAME=root \
  -e SPRING_DATASOURCE_PASSWORD=123456 \
  apolloconfig/apollo-configservice

Pull and run the Apollo Portal Server container with additional environment variables for portal configuration:

docker pull apolloconfig/apollo-portal
docker run -d --name apollo-portal \
  --net=host \
  -v /tmp/logs:/opt/logs \
  -e SPRING_DATASOURCE_URL="jdbc:mysql://192.168.20.57:3306/ApolloPortalDB?characterEncoding=utf8" \
  -e SPRING_DATASOURCE_USERNAME=root \
  -e SPRING_DATASOURCE_PASSWORD=123456 \
  -e APOLLO_PORTAL_ENVS=dev \
  -e DEV_META=http://192.168.20.57:8080 \
  apolloconfig/apollo-portal

Verify the services are running:

netstat -nltp
docker ps -a

Images illustrating the steps are included throughout the article.

End of tutorial.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DockerOperationsApollo
Practical DevOps Architecture
Written by

Practical DevOps Architecture

Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.